Skip to content

Commit cce501a

Browse files
authored
Add links to numcodecs docs in tutorial (#1535)
* Fix numcodecs links * Add release note
1 parent d756626 commit cce501a

File tree

3 files changed

+18
-8
lines changed

3 files changed

+18
-8
lines changed

docs/conf.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,7 @@ def setup(app):
331331
intersphinx_mapping = {
332332
"python": ("https://docs.python.org/", None),
333333
"numpy": ("https://numpy.org/doc/stable/", None),
334+
"numcodecs": ("https://numcodecs.readthedocs.io/en/stable/", None),
334335
}
335336

336337

docs/release.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@ Release notes
1818
Unreleased
1919
----------
2020

21+
Docs
22+
~~~~
23+
24+
* Add links to ``numcodecs`` docs in the tutorial.
25+
By :user:`David Stansby <dstansby>` :issue:`1535`.
26+
2127
Maintenance
2228
~~~~~~~~~~~
2329

@@ -33,6 +39,8 @@ Maintenance
3339
* Allow ``black`` code formatter to be run with any Python version.
3440
By :user:`David Stansby <dstansby>` :issue:`1549`.
3541

42+
43+
3644
.. _release_2.16.1:
3745

3846
2.16.1

docs/tutorial.rst

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1175,8 +1175,9 @@ A fixed-length unicode dtype is also available, e.g.::
11751175
For variable-length strings, the ``object`` dtype can be used, but a codec must be
11761176
provided to encode the data (see also :ref:`tutorial_objects` below). At the time of
11771177
writing there are four codecs available that can encode variable length string
1178-
objects: :class:`numcodecs.VLenUTF8`, :class:`numcodecs.JSON`, :class:`numcodecs.MsgPack`.
1179-
and :class:`numcodecs.Pickle`. E.g. using ``VLenUTF8``::
1178+
objects: :class:`numcodecs.vlen.VLenUTF8`, :class:`numcodecs.json.JSON`,
1179+
:class:`numcodecs.msgpacks.MsgPack`. and :class:`numcodecs.pickles.Pickle`.
1180+
E.g. using ``VLenUTF8``::
11801181

11811182
>>> import numcodecs
11821183
>>> z = zarr.array(text_data, dtype=object, object_codec=numcodecs.VLenUTF8())
@@ -1201,8 +1202,8 @@ is a short-hand for ``dtype=object, object_codec=numcodecs.VLenUTF8()``, e.g.::
12011202
'Helló, világ!', 'Zdravo svete!', 'เฮลโลเวิลด์'], dtype=object)
12021203

12031204
Variable-length byte strings are also supported via ``dtype=object``. Again an
1204-
``object_codec`` is required, which can be one of :class:`numcodecs.VLenBytes` or
1205-
:class:`numcodecs.Pickle`. For convenience, ``dtype=bytes`` (or ``dtype=str`` on Python
1205+
``object_codec`` is required, which can be one of :class:`numcodecs.vlen.VLenBytes` or
1206+
:class:`numcodecs.pickles.Pickle`. For convenience, ``dtype=bytes`` (or ``dtype=str`` on Python
12061207
2.7) can be used as a short-hand for ``dtype=object, object_codec=numcodecs.VLenBytes()``,
12071208
e.g.::
12081209

@@ -1218,7 +1219,7 @@ e.g.::
12181219
b'\xe0\xb9\x80\xe0\xb8\xae\xe0\xb8\xa5\xe0\xb9\x82\xe0\xb8\xa5\xe0\xb9\x80\xe0\xb8\xa7\xe0\xb8\xb4\xe0\xb8\xa5\xe0\xb8\x94\xe0\xb9\x8c'], dtype=object)
12191220

12201221
If you know ahead of time all the possible string values that can occur, you could
1221-
also use the :class:`numcodecs.Categorize` codec to encode each unique string value as an
1222+
also use the :class:`numcodecs.categorize.Categorize` codec to encode each unique string value as an
12221223
integer. E.g.::
12231224

12241225
>>> categorize = numcodecs.Categorize(greetings, dtype=object)
@@ -1245,7 +1246,7 @@ The best codec to use will depend on what type of objects are present in the arr
12451246

12461247
At the time of writing there are three codecs available that can serve as a general
12471248
purpose object codec and support encoding of a mixture of object types:
1248-
:class:`numcodecs.JSON`, :class:`numcodecs.MsgPack`. and :class:`numcodecs.Pickle`.
1249+
:class:`numcodecs.json.JSON`, :class:`numcodecs.msgpacks.MsgPack`. and :class:`numcodecs.pickles.Pickle`.
12491250

12501251
For example, using the JSON codec::
12511252

@@ -1258,7 +1259,7 @@ For example, using the JSON codec::
12581259
array([42, 'foo', list(['bar', 'baz', 'qux']), {'a': 1, 'b': 2.2}, None], dtype=object)
12591260

12601261
Not all codecs support encoding of all object types. The
1261-
:class:`numcodecs.Pickle` codec is the most flexible, supporting encoding any type
1262+
:class:`numcodecs.pickles.Pickle` codec is the most flexible, supporting encoding any type
12621263
of Python object. However, if you are sharing data with anyone other than yourself, then
12631264
Pickle is not recommended as it is a potential security risk. This is because malicious
12641265
code can be embedded within pickled data. The JSON and MsgPack codecs do not have any
@@ -1270,7 +1271,7 @@ Ragged arrays
12701271

12711272
If you need to store an array of arrays, where each member array can be of any length
12721273
and stores the same primitive type (a.k.a. a ragged array), the
1273-
:class:`numcodecs.VLenArray` codec can be used, e.g.::
1274+
:class:`numcodecs.vlen.VLenArray` codec can be used, e.g.::
12741275

12751276
>>> z = zarr.empty(4, dtype=object, object_codec=numcodecs.VLenArray(int))
12761277
>>> z

0 commit comments

Comments
 (0)