Skip to content

link_ancestors probably should work on immutable tables, but does not? #3311

@petrelharp

Description

@petrelharp

Currently

>>> ts = tskit.Tree.generate_comb(2).tree_sequence
>>> ts.link_ancestors()
Traceback (most recent call last):
  File "<python-input-6>", line 1, in <module>
    ts.link_ancestors()
    ^^^^^^^^^^^^^^^^^
AttributeError: 'TreeSequence' object has no attribute 'link_ancestors'
>>> ts.tables.link_ancestors()
Traceback (most recent call last):
  File "<python-input-7>", line 1, in <module>
    ts.tables.link_ancestors()
    ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/peter/projects/tskit-dev/tsvenv/lib/python3.13/site-packages/tskit/tables.py", line 4817, in __getattr__
    raise ImmutableTableError(
    ...<2 lines>...
    )
tskit.exceptions.ImmutableTableError: Cannot call link_ancestors() on immutable table collection. Use TreeSequence.dump_tables() for mutable copy.

but the docs for link_ancestors says

Returns an [EdgeTable](https://tskit.dev/tskit/docs/latest/python-api.html#tskit.EdgeTable) instance describing a subset of the genealogical relationships between the nodes in samples and ancestors.
...

and mentions nothing about modifying the tables that are passed in. I have not verified that it doesn't modify the tables.

So, I think this error is in error?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions