Skip to content

Commit 2545b34

Browse files
committed
Add tables.load docstring
Fixes #3406
1 parent f268aef commit 2545b34

2 files changed

Lines changed: 21 additions & 1 deletion

File tree

python/CHANGELOG.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ In development
1313
two-locus statistics in site and branch mode.
1414
(:user:`lkirk`, :user:`apragsdale`, :pr:`3416`)
1515
- Add `node_labels` parameter to `write_nexus`. (:user:`kaathewisegit`, :pr:`3442`)
16+
- Document ``TableCollection.load`` (:user:`hyanwong`, :issue:`3406` :pr:`3453`)
1617

1718
--------------------
1819
[1.0.2] - 2026-03-06

python/tskit/tables.py

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3455,6 +3455,24 @@ def __getstate__(self):
34553455

34563456
@classmethod
34573457
def load(cls, file_or_path, *, skip_tables=False, skip_reference_sequence=False):
3458+
"""
3459+
Load a :class:`TableCollection` from a file or path, saved in the format defined
3460+
by :meth:`.dump`. Although the file must be in the correct format, unlike
3461+
:func:`tskit.load` further validation is not performed to check that the tables
3462+
meet the :ref:`sec_valid_tree_sequence_requirements`. For instance,
3463+
unsorted tables can be loaded without error and then sorted before
3464+
:meth:`creating <TableCollection.tree_sequence>` a :class:`TreeSequence`.
3465+
3466+
:param file_or_path: The file object or path from which to load the
3467+
TableCollection.
3468+
:param bool skip_tables: If True, no tables are read from the file and
3469+
only the top-level information is populated in the returned TableCollection.
3470+
:param bool skip_reference_sequence: If True, tables are read
3471+
without loading any reference sequence.
3472+
:return: A TableCollection instance
3473+
:rtype: TableCollection
3474+
:raises: **tskit.FileFormatError** -- If the file is not in a valid format.
3475+
"""
34583476
file, local_file = util.convert_file_like_to_open_file(file_or_path, "rb")
34593477
ll_tc = _tskit.TableCollection()
34603478
try:
@@ -3474,7 +3492,8 @@ def dump(self, file_or_path):
34743492
"""
34753493
Writes the table collection to the specified path or file object.
34763494
3477-
:param str file_or_path: The file object or path to write the TreeSequence to.
3495+
:param str file_or_path: The file object or path to which to write this
3496+
TableCollection.
34783497
"""
34793498
file, local_file = util.convert_file_like_to_open_file(file_or_path, "wb")
34803499
try:

0 commit comments

Comments
 (0)