Skip to content

vectorised metadata extraction #1676

@petrelharp

Description

@petrelharp

A common thing people - at least with SLiM tree sequences - want to do is "get a vector of values from metadata where every object has the thing in metadata", e.g.

np.array([ind.metadata['slim_time'] for ind in ts.individuals()])

We do in pyslim, and @bodkan does this also (somewhat painfully?) in slendr using reticulate. The list comprehension is pretty easy to do, but to make it easier, perhaps there's an API we could make up? like

ts.metadata_vector('individuals', 'slim_time')

for instance? Perhaps with an optional default argument that provides the value to be used when the key is not present in a metadata?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Python APIIssue is about the Python APIenhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions