Skip to content

Commit 072b214

Browse files
hyanwongmergify[bot]
authored andcommitted
Clarify the set_columns behaviour for schemas
1 parent 9567c70 commit 072b214

File tree

1 file changed

+42
-21
lines changed

1 file changed

+42
-21
lines changed

python/tskit/tables.py

Lines changed: 42 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -632,9 +632,8 @@ def asdict(self):
632632

633633
def set_columns(self, **kwargs):
634634
"""
635-
Sets the values for each column in this :class:`Table` using
636-
values provided in numpy arrays. Overwrites any data currently stored in
637-
the table.
635+
Sets the values for each column in this :class:`Table` using values
636+
provided in numpy arrays. Overwrites existing data in all the table columns.
638637
"""
639638
raise NotImplementedError()
640639

@@ -912,8 +911,8 @@ def set_columns(
912911
):
913912
"""
914913
Sets the values for each column in this :class:`IndividualTable` using the
915-
values in the specified arrays. Overwrites any data currently stored in
916-
the table.
914+
values in the specified arrays. Overwrites existing data in all the table
915+
columns.
917916
918917
The ``flags`` array is mandatory and defines the number of individuals
919918
the table will contain.
@@ -946,7 +945,11 @@ def set_columns(
946945
:type metadata: numpy.ndarray, dtype=np.int8
947946
:param metadata_offset: The offsets into the ``metadata`` array.
948947
:type metadata_offset: numpy.ndarray, dtype=np.uint32.
949-
:param metadata_schema: The encoded metadata schema.
948+
:param metadata_schema: The encoded metadata schema. If None (default)
949+
do not overwrite the exising schema. Note that a schema will need to be
950+
encoded as a string, e.g. via ``repr(new_metadata_schema)``.
951+
:type metadata_schema: str
952+
950953
"""
951954
self._check_required_args(flags=flags)
952955
self.ll_table.set_columns(
@@ -1161,7 +1164,7 @@ def set_columns(
11611164
):
11621165
"""
11631166
Sets the values for each column in this :class:`NodeTable` using the values in
1164-
the specified arrays. Overwrites any data currently stored in the table.
1167+
the specified arrays. Overwrites existing data in all the table columns.
11651168
11661169
The ``flags``, ``time`` and ``population`` arrays must all be of the same length,
11671170
which is equal to the number of nodes the table will contain. The
@@ -1186,7 +1189,10 @@ def set_columns(
11861189
:type metadata: numpy.ndarray, dtype=np.int8
11871190
:param metadata_offset: The offsets into the ``metadata`` array.
11881191
:type metadata_offset: numpy.ndarray, dtype=np.uint32.
1189-
:param metadata_schema: The encoded metadata schema.
1192+
:param metadata_schema: The encoded metadata schema. If None (default)
1193+
do not overwrite the exising schema. Note that a schema will need to be
1194+
encoded as a string, e.g. via ``repr(new_metadata_schema)``.
1195+
:type metadata_schema: str
11901196
"""
11911197
self._check_required_args(flags=flags, time=time)
11921198
self.ll_table.set_columns(
@@ -1359,7 +1365,7 @@ def set_columns(
13591365
):
13601366
"""
13611367
Sets the values for each column in this :class:`EdgeTable` using the values
1362-
in the specified arrays. Overwrites any data currently stored in the table.
1368+
in the specified arrays. Overwrites existing data in all the table columns.
13631369
13641370
The ``left``, ``right``, ``parent`` and ``child`` parameters are mandatory,
13651371
and must be numpy arrays of the same length (which is equal to the number of
@@ -1384,7 +1390,10 @@ def set_columns(
13841390
:type metadata: numpy.ndarray, dtype=np.int8
13851391
:param metadata_offset: The offsets into the ``metadata`` array.
13861392
:type metadata_offset: numpy.ndarray, dtype=np.uint32.
1387-
:param metadata_schema: The encoded metadata schema.
1393+
:param metadata_schema: The encoded metadata schema. If None (default)
1394+
do not overwrite the exising schema. Note that a schema will need to be
1395+
encoded as a string, e.g. via ``repr(new_metadata_schema)``.
1396+
:type metadata_schema: str
13881397
"""
13891398
self._check_required_args(left=left, right=right, parent=parent, child=child)
13901399
self.ll_table.set_columns(
@@ -1585,7 +1594,7 @@ def set_columns(
15851594
):
15861595
"""
15871596
Sets the values for each column in this :class:`MigrationTable` using the values
1588-
in the specified arrays. Overwrites any data currently stored in the table.
1597+
in the specified arrays. Overwrites existing data in all the table columns.
15891598
15901599
All parameters except ``metadata`` and ``metadata_offset`` and are mandatory,
15911600
and must be numpy arrays of the same length (which is equal to the number of
@@ -1613,7 +1622,10 @@ def set_columns(
16131622
:type metadata: numpy.ndarray, dtype=np.int8
16141623
:param metadata_offset: The offsets into the ``metadata`` array.
16151624
:type metadata_offset: numpy.ndarray, dtype=np.uint32.
1616-
:param metadata_schema: The encoded metadata schema.
1625+
:param metadata_schema: The encoded metadata schema. If None (default)
1626+
do not overwrite the exising schema. Note that a schema will need to be
1627+
encoded as a string, e.g. via ``repr(new_metadata_schema)``.
1628+
:type metadata_schema: str
16171629
"""
16181630
self._check_required_args(
16191631
left=left, right=right, node=node, source=source, dest=dest, time=time
@@ -1791,7 +1803,7 @@ def set_columns(
17911803
):
17921804
"""
17931805
Sets the values for each column in this :class:`SiteTable` using the values
1794-
in the specified arrays. Overwrites any data currently stored in the table.
1806+
in the specified arrays. Overwrites existing data in all the table columns.
17951807
17961808
The ``position``, ``ancestral_state`` and ``ancestral_state_offset``
17971809
parameters are mandatory, and must be 1D numpy arrays. The length
@@ -1818,7 +1830,10 @@ def set_columns(
18181830
:type metadata: numpy.ndarray, dtype=np.int8
18191831
:param metadata_offset: The offsets into the ``metadata`` array.
18201832
:type metadata_offset: numpy.ndarray, dtype=np.uint32.
1821-
:param metadata_schema: The encoded metadata schema.
1833+
:param metadata_schema: The encoded metadata schema. If None (default)
1834+
do not overwrite the exising schema. Note that a schema will need to be
1835+
encoded as a string, e.g. via ``repr(new_metadata_schema)``.
1836+
:type metadata_schema: str
18221837
"""
18231838
self._check_required_args(
18241839
position=position,
@@ -2032,7 +2047,7 @@ def set_columns(
20322047
):
20332048
"""
20342049
Sets the values for each column in this :class:`MutationTable` using the values
2035-
in the specified arrays. Overwrites any data currently stored in the table.
2050+
in the specified arrays. Overwrites existing data in all the the table columns.
20362051
20372052
The ``site``, ``node``, ``derived_state`` and ``derived_state_offset``
20382053
parameters are mandatory, and must be 1D numpy arrays. The
@@ -2066,7 +2081,10 @@ def set_columns(
20662081
:type metadata: numpy.ndarray, dtype=np.int8
20672082
:param metadata_offset: The offsets into the ``metadata`` array.
20682083
:type metadata_offset: numpy.ndarray, dtype=np.uint32.
2069-
:param metadata_schema: The encoded metadata schema.
2084+
:param metadata_schema: The encoded metadata schema. If None (default)
2085+
do not overwrite the exising schema. Note that a schema will need to be
2086+
encoded as a string, e.g. via ``repr(new_metadata_schema)``.
2087+
:type metadata_schema: str
20702088
"""
20712089
self._check_required_args(
20722090
site=site,
@@ -2235,8 +2253,8 @@ def _text_header_and_rows(self, limit=None):
22352253
def set_columns(self, metadata=None, metadata_offset=None, metadata_schema=None):
22362254
"""
22372255
Sets the values for each column in this :class:`PopulationTable` using the
2238-
values in the specified arrays. Overwrites any data currently stored in the
2239-
table.
2256+
values in the specified arrays. Overwrites existing data in all the table
2257+
columns.
22402258
22412259
The ``metadata`` and ``metadata_offset`` parameters must be supplied
22422260
together, and meet the requirements for
@@ -2250,7 +2268,10 @@ def set_columns(self, metadata=None, metadata_offset=None, metadata_schema=None)
22502268
:type metadata: numpy.ndarray, dtype=np.int8
22512269
:param metadata_offset: The offsets into the ``metadata`` array.
22522270
:type metadata_offset: numpy.ndarray, dtype=np.uint32.
2253-
:param metadata_schema: The encoded metadata schema.
2271+
:param metadata_schema: The encoded metadata schema. If None (default)
2272+
do not overwrite the exising schema. Note that a schema will need to be
2273+
encoded as a string, e.g. via ``repr(new_metadata_schema)``.
2274+
:type metadata_schema: str
22542275
"""
22552276
self.ll_table.set_columns(
22562277
dict(
@@ -2405,8 +2426,8 @@ def set_columns(
24052426
):
24062427
"""
24072428
Sets the values for each column in this :class:`ProvenanceTable` using the
2408-
values in the specified arrays. Overwrites any data currently stored in the
2409-
table.
2429+
values in the specified arrays. Overwrites existing data in all the table
2430+
columns.
24102431
24112432
The ``timestamp`` and ``timestamp_offset`` parameters must be supplied
24122433
together, and meet the requirements for

0 commit comments

Comments
 (0)