Skip to content

Commit

Permalink
rename merge to mergedata
Browse files Browse the repository at this point in the history
  • Loading branch information
axsk committed Aug 23, 2024
1 parent 2b498b8 commit be88b74
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 6 deletions.
2 changes: 0 additions & 2 deletions scripts/multitraj.jl
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ datas = map(trajfiles) do trajfile
data = data_from_trajectory(feats, reverse=true)
end

mergedata(d1, d2) = lastcat.(d1, d2)

data = reduce(mergedata, datas)

iso = Iso(data)
Expand Down
1 change: 1 addition & 0 deletions src/data.jl
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ function adddata(data, model, sim, ny)
return joindata(data, (xs, ys))
end

mergedata(d1::Tuple, d2::Tuple) = lastcat.(d1, d2)

lastcat(x::T, y::T) where {N,T<:AbstractArray{<:Any,N}} = cat(x, y, dims=N)
lastcat(x::T, y) where {T} = lastcat(x, convert(T, y))
Expand Down
2 changes: 1 addition & 1 deletion src/extrapolate.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ function addextrapolates!(iso, n; stepsize=0.01, steps=1)
n == 0 && return
xs = extrapolate(iso, n, stepsize, steps)
nd = SimulationData(iso.data.sim, xs, nk(iso.data))
iso.data = merge(iso.data, nd)
iso.data = mergedata(iso.data, nd)
return
end

Expand Down
9 changes: 6 additions & 3 deletions src/simulation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -131,12 +131,12 @@ pdb(s::SimulationData) = pdb(s.sim)


"""
merge(d1::SimulationData, d2::SimulationData)
mergedata(d1::SimulationData, d2::SimulationData)
Merge the data and features of `d1` and `d2`, keeping the simulation and features of `d1`.
Note that there is no check if simulation features agree.
"""
function Base.merge(d1::SimulationData, d2::SimulationData)
function mergedata(d1::SimulationData, d2::SimulationData)
coords = lastcat.(d1.coords, d2.coords)
d2f = if d1.featurizer == d2.featurizer
d2.features
Expand All @@ -147,8 +147,11 @@ function Base.merge(d1::SimulationData, d2::SimulationData)
return SimulationData(d1.sim, features, coords, d1.featurizer)
end

@deprecate Base.merge(d1::SimulationData, d2::SimulationData) mergedata(d1, d2) false


function addcoords(d::SimulationData, coords::AbstractMatrix)
merge(d, SimulationData(d.sim, coords, nk(d), featurizer=d.featurizer))
mergedata(d, SimulationData(d.sim, coords, nk(d), featurizer=d.featurizer))
end


Expand Down

0 comments on commit be88b74

Please sign in to comment.