Skip to content

Commit 509636f

Browse files
Merge pull request #408 from jeromekelleher/fix-sphinx-nitpicks
Fix sphinx nitpicks.
2 parents cb454e6 + 46d133b commit 509636f

File tree

9 files changed

+191
-106
lines changed

9 files changed

+191
-106
lines changed

docs/conf.py

Lines changed: 4 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,10 @@ def handle_item(fieldarg, content):
263263
# -- Options for intersphinx extension ---------------------------------------
264264

265265
# Example configuration for intersphinx: refer to the Python standard library.
266-
intersphinx_mapping = {'https://docs.python.org/': None}
266+
intersphinx_mapping = {
267+
'https://docs.python.org/': None,
268+
'http://docs.scipy.org/doc/numpy/': None,
269+
}
267270

268271
# -- Options for todo extension ----------------------------------------------
269272

@@ -287,7 +290,6 @@ def handle_item(fieldarg, content):
287290
("c:type", "bool"),
288291
# TODO these have been triaged here to make the docs compile, but we should
289292
# sort them out properly. https://github.com/tskit-dev/tskit/issues/336
290-
("py:class", "a"),
291293
("py:class", "ndarray"),
292294
("py:class", "numpy array"),
293295
("py:class", "numpy.ndarray"),
@@ -303,29 +305,7 @@ def handle_item(fieldarg, content):
303305
("py:class", "dtype=np.int8"),
304306
("py:class", "dtype=np.float64"),
305307
("py:class", "dtype=np.int64"),
306-
("py:class", "iter"),
307-
("py:class", "iterator"),
308-
("py:class", "map"),
309308
("py:class", "array"),
310309
("py:class", "array_like"),
311-
("py:class", "File"),
312-
("py:class", "callable"),
313-
("py:class", "stream"),
314-
("py:class", "string"),
315310
("py:class", ""),
316-
("py:class", "Provenance"),
317-
("py:class", "ProvenanceValidationError"),
318-
("py:class", "function"),
319-
("py:class", "Table"),
320-
("py:const", "tskit.FORWARD"),
321-
("py:const", "tskit.REVERSE"),
322-
("py:const", "NULL"),
323-
("py:attr", "NULL"),
324-
("py:func", "numpy.round"),
325-
("py:func", "numpy.nonzero"),
326-
("py:func", "pack_bytes"),
327-
("py:func", "unpack_bytes"),
328-
("py:func", "parse_individuals"),
329-
("py:func", "parse_populations"),
330-
("py:meth", "Tree.get_num_tracked_samples"),
331311
]

docs/data-model.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1132,6 +1132,7 @@ mutations::
11321132
1 1 A 1
11331133

11341134

1135+
.. _sec_population_text_format:
11351136

11361137
Population text format
11371138
======================

docs/python-api.rst

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -36,19 +36,20 @@ Top level-classes
3636
Constants
3737
+++++++++
3838

39-
.. data:: tskit.NULL == -1
39+
.. autodata:: tskit.NULL
40+
:annotation: = -1
4041

41-
Special reserved value representing a null ID.
42+
.. autodata:: tskit.NODE_IS_SAMPLE
43+
:annotation: = 1
4244

43-
.. data:: tskit.FORWARD == 1
45+
.. autodata:: tskit.MISSING_DATA
46+
:annotation: = -1
4447

45-
Constant representing the forward direction of travel (i.e.,
46-
increasing genomic coordinate values).
48+
.. autodata:: tskit.FORWARD
49+
:annotation: = 1
4750

48-
.. data:: tskit.REVERSE == -1
49-
50-
Constant representing the reverse direction of travel (i.e.,
51-
decreasing genomic coordinate values).
51+
.. autodata:: tskit.REVERSE
52+
:annotation: = -1
5253

5354

5455
++++++++++++++++++++++++
@@ -84,6 +85,9 @@ directly, but are the return types for the various iterators provided by the
8485
.. autoclass:: tskit.Population()
8586
:members:
8687

88+
.. autoclass:: tskit.Provenance()
89+
:members:
90+
8791
++++++++++++
8892
Loading data
8993
++++++++++++
@@ -352,7 +356,7 @@ encoded as signed integers. As for :ref:`sec_tables_api_text_columns`,
352356
the ``metadata_offset`` column encodes the offsets into this array. So, we
353357
see that the first metadata value is 9 bytes long and the second is 24.
354358

355-
The :func:`pack_bytes` and :func:`unpack_bytes` functions are also useful
359+
The :func:`.pack_bytes` and :func:`.unpack_bytes` functions are also useful
356360
for encoding data in these columns.
357361

358362
+++++++++++++
@@ -430,6 +434,10 @@ Table functions
430434

431435
.. autofunction:: tskit.parse_mutations
432436

437+
.. autofunction:: tskit.parse_individuals
438+
439+
.. autofunction:: tskit.parse_populations
440+
433441
.. autofunction:: tskit.pack_strings
434442

435443
.. autofunction:: tskit.unpack_strings

docs/tutorial.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ The ``tskit`` Tree implementation differs from most tree libraries by
1919
using **integer IDs** to refer to nodes rather than objects. Thus, when we wish to
2020
find the parent of the node with ID '0', we use ``tree.parent(0)``, which
2121
returns another integer. If '0' does not have a parent in the current tree
22-
(e.g., if it is a root), then the special value :const:`.NULL`
22+
(e.g., if it is a root), then the special value :data:`.NULL`
2323
(:math:`-1`) is returned. The children of a node are found using the
2424
:meth:`.Tree.children` method. To obtain information about a particular node,
2525
one may either use ``tree.tree_sequence.node(u)`` to which returns the

python/tskit/__init__.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,22 @@
2121
# SOFTWARE.
2222

2323
import _tskit
24+
25+
#: Special reserved value representing a null ID.
2426
NULL = _tskit.NULL
27+
28+
#: Special value representing missing data in a genotype array
2529
MISSING_DATA = _tskit.MISSING_DATA
30+
31+
#: Node flag value indicating that it is a sample.
2632
NODE_IS_SAMPLE = _tskit.NODE_IS_SAMPLE
33+
34+
#: Constant representing the forward direction of travel (i.e.,
35+
#: increasing genomic coordinate values).
2736
FORWARD = _tskit.FORWARD
37+
38+
#: Constant representing the reverse direction of travel (i.e.,
39+
#: decreasing genomic coordinate values).
2840
REVERSE = _tskit.REVERSE
2941

3042
from tskit.provenance import __version__ # NOQA

python/tskit/provenance.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ def validate_provenance(provenance):
125125
126126
:param dict provenance: The dictionary representing a JSON document
127127
to be validated against the schema.
128-
:raises: :class:`.ProvenanceValidationError`
128+
:raises: :class:`tskit.ProvenanceValidationError`
129129
"""
130130
schema = get_schema()
131131
try:

python/tskit/stats.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,18 +95,18 @@ def r2_array(self, a, direction=1, max_mutations=None, max_distance=None):
9595
:math:`b` considered, we then insert the value of :math:`r^2` between
9696
:math:`a` and :math:`b` at the corresponding index in an array, and
9797
return the entire array. If the returned array is :math:`x` and
98-
``direction`` is :const:`tskit.FORWARD` then :math:`x[0]` is the
98+
``direction`` is :data:`tskit.FORWARD` then :math:`x[0]` is the
9999
value of the statistic for :math:`a` and :math:`a + 1`, :math:`x[1]`
100100
the value for :math:`a` and :math:`a + 2`, etc. Similarly, if
101-
``direction`` is :const:`tskit.REVERSE` then :math:`x[0]` is the
101+
``direction`` is :data:`tskit.REVERSE` then :math:`x[0]` is the
102102
value of the statistic for :math:`a` and :math:`a - 1`, :math:`x[1]`
103103
the value for :math:`a` and :math:`a - 2`, etc.
104104
105105
:param int a: The index of the focal mutation.
106106
:param int direction: The direction in which to travel when
107107
examining other mutations. Must be either
108-
:const:`tskit.FORWARD` or :const:`tskit.REVERSE`. Defaults
109-
to :const:`tskit.FORWARD`.
108+
:data:`tskit.FORWARD` or :data:`tskit.REVERSE`. Defaults
109+
to :data:`tskit.FORWARD`.
110110
:param int max_mutations: The maximum number of mutations to return
111111
:math:`r^2` values for. Defaults to as many mutations as
112112
possible.

python/tskit/tables.py

Lines changed: 86 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -435,9 +435,9 @@ def add_row(self, flags=0, time=0, population=-1, individual=-1, metadata=None):
435435
:param int flags: The bitwise flags for the new node.
436436
:param float time: The birth time for the new node.
437437
:param int population: The ID of the population in which the new node was born.
438-
Defaults to :const:`.NULL`.
438+
Defaults to :data:`.NULL`.
439439
:param int individual: The ID of the individual in which the new node was born.
440-
Defaults to :const:`.NULL`.
440+
Defaults to :data:`.NULL`.
441441
:param bytes metadata: The binary-encoded metadata for the new node. If not
442442
specified or None, a zero-length byte string is stored.
443443
:return: The ID of the newly added node.
@@ -463,10 +463,10 @@ def set_columns(
463463
:param time: The time values for each node. Required.
464464
:type time: numpy.ndarray, dtype=np.float64
465465
:param population: The population values for each node. If not specified
466-
or None, the :const:`.NULL` value is stored for each node.
466+
or None, the :data:`.NULL` value is stored for each node.
467467
:type population: numpy.ndarray, dtype=np.int32
468468
:param individual: The individual values for each node. If not specified
469-
or None, the :const:`.NULL` value is stored for each node.
469+
or None, the :data:`.NULL` value is stored for each node.
470470
:type individual: numpy.ndarray, dtype=np.int32
471471
:param metadata: The flattened metadata array. Must be specified along
472472
with ``metadata_offset``. If not specified or None, an empty metadata
@@ -498,10 +498,10 @@ def append_columns(
498498
:param time: The time values for each node. Required.
499499
:type time: numpy.ndarray, dtype=np.float64
500500
:param population: The population values for each node. If not specified
501-
or None, the :const:`.NULL` value is stored for each node.
501+
or None, the :data:`.NULL` value is stored for each node.
502502
:type population: numpy.ndarray, dtype=np.int32
503503
:param individual: The individual values for each node. If not specified
504-
or None, the :const:`.NULL` value is stored for each node.
504+
or None, the :data:`.NULL` value is stored for each node.
505505
:type individual: numpy.ndarray, dtype=np.int32
506506
:param metadata: The flattened metadata array. Must be specified along
507507
with ``metadata_offset``. If not specified or None, an empty metadata
@@ -1140,10 +1140,43 @@ def __str__(self):
11401140
return ret[:-1]
11411141

11421142
def set_columns(self, metadata=None, metadata_offset=None):
1143+
"""
1144+
Sets the values for each column in this :class:`.PopulationTable` using the
1145+
values in the specified arrays. Overwrites any data currently stored in the
1146+
table.
1147+
1148+
The ``metadata`` and ``metadata_offset`` parameters must be supplied
1149+
together, and meet the requirements for
1150+
:ref:`sec_encoding_ragged_columns` (see
1151+
:ref:`sec_tables_api_binary_columns` for more information).
1152+
1153+
:param metadata: The flattened metadata array. Must be specified along
1154+
with ``metadata_offset``. If not specified or None, an empty metadata
1155+
value is stored for each node.
1156+
:type metadata: numpy.ndarray, dtype=np.int8
1157+
:param metadata_offset: The offsets into the ``metadata`` array.
1158+
:type metadata_offset: numpy.ndarray, dtype=np.uint32.
1159+
"""
11431160
self.ll_table.set_columns(
11441161
dict(metadata=metadata, metadata_offset=metadata_offset))
11451162

11461163
def append_columns(self, metadata=None, metadata_offset=None):
1164+
"""
1165+
Appends the specified arrays to the end of the columns of this
1166+
:class:`PopulationTable`. This allows many new rows to be added at once.
1167+
1168+
The ``metadata`` and ``metadata_offset`` parameters must be supplied
1169+
together, and meet the requirements for
1170+
:ref:`sec_encoding_ragged_columns` (see
1171+
:ref:`sec_tables_api_binary_columns` for more information).
1172+
1173+
:param metadata: The flattened metadata array. Must be specified along
1174+
with ``metadata_offset``. If not specified or None, an empty metadata
1175+
value is stored for each node.
1176+
:type metadata: numpy.ndarray, dtype=np.int8
1177+
:param metadata_offset: The offsets into the ``metadata`` array.
1178+
:type metadata_offset: numpy.ndarray, dtype=np.uint32.
1179+
"""
11471180
self.ll_table.append_columns(
11481181
dict(metadata=metadata, metadata_offset=metadata_offset))
11491182

@@ -1201,13 +1234,60 @@ def add_row(self, record, timestamp=None):
12011234
def set_columns(
12021235
self, timestamp=None, timestamp_offset=None,
12031236
record=None, record_offset=None):
1237+
"""
1238+
Sets the values for each column in this :class:`.ProvenanceTable` using the
1239+
values in the specified arrays. Overwrites any data currently stored in the
1240+
table.
1241+
1242+
The ``timestamp`` and ``timestamp_offset`` parameters must be supplied
1243+
together, and meet the requirements for
1244+
:ref:`sec_encoding_ragged_columns` (see
1245+
:ref:`sec_tables_api_binary_columns` for more information). Likewise
1246+
for the ``record`` and ``record_offset`` columns
1247+
1248+
:param timestamp: The flattened timestamp array. Must be specified along
1249+
with ``timestamp_offset``. If not specified or None, an empty timestamp
1250+
value is stored for each node.
1251+
:type timestamp: numpy.ndarray, dtype=np.int8
1252+
:param timestamp_offset: The offsets into the ``timestamp`` array.
1253+
:type timestamp_offset: numpy.ndarray, dtype=np.uint32.
1254+
:param record: The flattened record array. Must be specified along
1255+
with ``record_offset``. If not specified or None, an empty record
1256+
value is stored for each node.
1257+
:type record: numpy.ndarray, dtype=np.int8
1258+
:param record_offset: The offsets into the ``record`` array.
1259+
:type record_offset: numpy.ndarray, dtype=np.uint32.
1260+
"""
12041261
self.ll_table.set_columns(dict(
12051262
timestamp=timestamp, timestamp_offset=timestamp_offset,
12061263
record=record, record_offset=record_offset))
12071264

12081265
def append_columns(
12091266
self, timestamp=None, timestamp_offset=None,
12101267
record=None, record_offset=None):
1268+
"""
1269+
Appends the specified arrays to the end of the columns of this
1270+
:class:`ProvenanceTable`. This allows many new rows to be added at once.
1271+
1272+
The ``timestamp`` and ``timestamp_offset`` parameters must be supplied
1273+
together, and meet the requirements for
1274+
:ref:`sec_encoding_ragged_columns` (see
1275+
:ref:`sec_tables_api_binary_columns` for more information). Likewise
1276+
for the ``record`` and ``record_offset`` columns
1277+
1278+
:param timestamp: The flattened timestamp array. Must be specified along
1279+
with ``timestamp_offset``. If not specified or None, an empty timestamp
1280+
value is stored for each node.
1281+
:type timestamp: numpy.ndarray, dtype=np.int8
1282+
:param timestamp_offset: The offsets into the ``timestamp`` array.
1283+
:type timestamp_offset: numpy.ndarray, dtype=np.uint32.
1284+
:param record: The flattened record array. Must be specified along
1285+
with ``record_offset``. If not specified or None, an empty record
1286+
value is stored for each node.
1287+
:type record: numpy.ndarray, dtype=np.int8
1288+
:param record_offset: The offsets into the ``record`` array.
1289+
:type record_offset: numpy.ndarray, dtype=np.uint32.
1290+
"""
12111291
self.ll_table.append_columns(dict(
12121292
timestamp=timestamp, timestamp_offset=timestamp_offset,
12131293
record=record, record_offset=record_offset))

0 commit comments

Comments
 (0)