Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions python/CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ In development
two-locus statistics in site and branch mode.
(:user:`lkirk`, :user:`apragsdale`, :pr:`3416`)
- Add `node_labels` parameter to `write_nexus`. (:user:`kaathewisegit`, :pr:`3442`)
- Document ``TableCollection.load`` (:user:`hyanwong`, :issue:`3406` :pr:`3453`)

--------------------
[1.0.2] - 2026-03-06
Expand Down
21 changes: 20 additions & 1 deletion python/tskit/tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -3455,6 +3455,24 @@ def __getstate__(self):

@classmethod
def load(cls, file_or_path, *, skip_tables=False, skip_reference_sequence=False):
"""
Load a :class:`TableCollection` from a file or path, saved in the format defined
by :meth:`.dump`. Although the file must be in the correct format, unlike
:func:`tskit.load` further validation is not performed to check that the tables
meet the :ref:`sec_valid_tree_sequence_requirements`. For instance,
unsorted tables can be loaded without error and then sorted before
:meth:`creating <TableCollection.tree_sequence>` a :class:`TreeSequence`.

:param file_or_path: The file object or path from which to load the
TableCollection.
:param bool skip_tables: If True, no tables are read from the file and
only the top-level information is populated in the returned TableCollection.
:param bool skip_reference_sequence: If True, tables are read
without loading any reference sequence.
:return: A TableCollection instance
:rtype: TableCollection
:raises: **tskit.FileFormatError** -- If the file is not in a valid format.
"""
file, local_file = util.convert_file_like_to_open_file(file_or_path, "rb")
ll_tc = _tskit.TableCollection()
try:
Expand All @@ -3474,7 +3492,8 @@ def dump(self, file_or_path):
"""
Writes the table collection to the specified path or file object.

:param str file_or_path: The file object or path to write the TreeSequence to.
:param str file_or_path: The file object or path to which to write this
TableCollection.
"""
file, local_file = util.convert_file_like_to_open_file(file_or_path, "wb")
try:
Expand Down
Loading