-
Notifications
You must be signed in to change notification settings - Fork 77
Closed
Labels
Python APIIssue is about the Python APIIssue is about the Python API
Milestone
Description
Discussed in #1543
Originally posted by hyanwong June 30, 2021
At the moment I think adding to the metadata arrays (e.g. on populations, individuals, or nodes) is quite intricate, and I have to look it up every time. I think it's something like this:
ts = msprime.sim_ancestry(10)
tables = ts.dump_tables()
pop_metadatas = [p.metadata for p in ts.populations()] # Why is there no tables.population.get_metadatas() method?
pop_metadatas[0]['name'] += "(the only population)"
tables.populations.packset_metadata(
[tables.populations.metadata_schema.validate_and_encode_row(r) for r in pop_metadatas])
new_ts = tables.tree_sequence()
print([p for p in new_ts.populations()])
(it looks me about 10 minutes to look up how to do that, and the information is scattered all over the docs - I don't think a beginner could do it TBH).
Should we have some convenience methods to help with this? I quite often want to edit metadata on just a single entry in a table: e.g. label a particular individual, flag up a single node, etc.
We should also give an example of doing this in the metadata tutorial
Metadata
Metadata
Assignees
Labels
Python APIIssue is about the Python APIIssue is about the Python API