Skip to content

Commit

Permalink
Merge pull request #43 from kestrelquantum/patch_get_components
Browse files Browse the repository at this point in the history
add cnames for partial get_comps
  • Loading branch information
andgoldschmidt authored Jun 26, 2024
2 parents c07ad12 + 72bda33 commit b6c3224
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/methods_named_trajectory.jl
Original file line number Diff line number Diff line change
Expand Up @@ -71,16 +71,17 @@ end


"""
components(::NamedTrajectory)
get_components(::NamedTrajectory)
Returns a NamedTuple containing the names and corresponding data matrices of the trajectory.
"""
function get_components(traj::NamedTrajectory)
data = [traj[comp] for comp traj.names]
return NamedTuple(zip(traj.names, data))
function get_components(cnames::Union{Tuple, AbstractVector}, traj::NamedTrajectory)
symbs = Tuple(c for c in cnames)
vals = [traj[c] for c cnames]
return NamedTuple{symbs}(vals)
end


get_components(traj::NamedTrajectory) = get_components(traj.names, traj)


"""
Expand Down

0 comments on commit b6c3224

Please sign in to comment.