Skip to content

Commit 1f32d1f

Browse files
committed
documentation
1 parent 478ced7 commit 1f32d1f

File tree

13 files changed

+394
-73
lines changed

13 files changed

+394
-73
lines changed

docs/api/creation.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Array creation (``zarr.creation``)
77
.. autofunction:: ones
88
.. autofunction:: full
99
.. autofunction:: array
10-
.. autofunction:: open
10+
.. autofunction:: open_array
1111
.. autofunction:: empty_like
1212
.. autofunction:: zeros_like
1313
.. autofunction:: ones_like

docs/api/hierarchy.rst

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,31 @@ Groups (``zarr.hierarchy``)
77

88
.. autoclass:: Group
99

10+
.. automethod:: __len__
11+
.. automethod:: __contains__
1012
.. automethod:: __getitem__
13+
.. automethod:: __setitem__
14+
.. automethod:: __iter__
15+
.. automethod:: keys
16+
.. automethod:: values
17+
.. automethod:: items
18+
.. automethod:: group_keys
19+
.. automethod:: groups
20+
.. automethod:: array_keys
21+
.. automethod:: arrays
1122
.. automethod:: create_group
1223
.. automethod:: require_group
24+
.. automethod:: create_groups
25+
.. automethod:: require_groups
1326
.. automethod:: create_dataset
1427
.. automethod:: require_dataset
28+
.. automethod:: create
29+
.. automethod:: empty
30+
.. automethod:: zeros
31+
.. automethod:: ones
32+
.. automethod:: full
33+
.. automethod:: array
34+
.. automethod:: empty_like
35+
.. automethod:: zeros_like
36+
.. automethod:: ones_like
37+
.. automethod:: full_like

docs/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ Highlights
1616
* Store arrays in memory, on disk, inside a Zip file, on S3, ...
1717
* Read an array concurrently from multiple threads or processes.
1818
* Write to an array concurrently from multiple threads or processes.
19+
* Organize arrays into hierarchies via groups.
1920

2021
Status
2122
------

docs/release.rst

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,21 @@
11
Release notes
22
=============
33

4+
.. _release_2.0.0:
5+
6+
2.0.0
7+
-----
8+
9+
Hierarchies
10+
~~~~~~~~~~~
11+
12+
Support has been added for organizing arrays into hierarchies via groups. See
13+
the tutorial section on :ref:`tutorial_groups` and the :mod:`zarr.hierarchy`
14+
API docs for more information.
15+
16+
To accommodate support for hierarchies the Zarr format has been modified. See
17+
the :ref:`spec_v2` for more information.
18+
419
.. _release_1.1.0:
520

621
1.1.0

docs/spec/v2.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ file system).
193193
Groups
194194
~~~~~~
195195

196-
Arrays can be organised into groups which can also contain other groups. A
196+
Arrays can be organized into groups which can also contain other groups. A
197197
group is created by storing group metadata under the '.zgroup' key under some
198198
logical path. E.g., a group exists at the root of an array store if the
199199
'.zgroup' key exists in the store, and a group exists at logical path 'foo/bar'

docs/tutorial.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ and can be configured in a variety of ways to improve the compression
178178
ratio for different types of data. Blosc is in fact a
179179
"meta-compressor", which means that it can used a number of different
180180
compression algorithms internally to compress the data. Blosc also
181-
provides highly optimised implementations of byte and bit shuffle
181+
provides highly optimized implementations of byte and bit shuffle
182182
filters, which can significantly improve compression ratios for some
183183
data.
184184

zarr/compressors.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ def normalize_opts(cls, compression_opts):
138138
if shuffle not in [0, 1, 2]:
139139
raise ValueError('invalid shuffle: %s' % shuffle)
140140

141-
# construct normalised options
141+
# construct normalized options
142142
compression_opts = dict(
143143
cname=cname, clevel=clevel, shuffle=shuffle
144144
)

zarr/core.py

Lines changed: 13 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
# -*- coding: utf-8 -*-
22
from __future__ import absolute_import, print_function, division
3-
from functools import reduce # TODO PY2 compatibility
43
import operator
54
import itertools
65

@@ -17,21 +16,25 @@
1716
from zarr.meta import decode_array_metadata, encode_array_metadata
1817
from zarr.attrs import Attributes
1918
from zarr.errors import ReadOnlyError
19+
from zarr.compat import reduce
2020

2121

2222
class Array(object):
23-
"""Instantiate an array from an initialised store.
23+
"""Instantiate an array from an initialized store.
2424
2525
Parameters
2626
----------
2727
store : MutableMapping
28-
Array store, already initialised.
28+
Array store, already initialized.
29+
path : string, optional
30+
Storage path.
2931
readonly : bool, optional
3032
True if array should be protected against modification.
3133
3234
Attributes
3335
----------
3436
store
37+
path
3538
name
3639
readonly
3740
shape
@@ -56,23 +59,11 @@ class Array(object):
5659
resize
5760
append
5861
59-
Examples
60-
--------
61-
>>> import zarr
62-
>>> store = dict()
63-
>>> zarr.init_array(store, shape=(10000, 10000), chunks=(1000, 1000))
64-
>>> z = zarr.Array(store)
65-
>>> z
66-
zarr.core.Array((10000, 10000), float64, chunks=(1000, 1000), order=C)
67-
compression: blosc; compression_opts: {'clevel': 5, 'cname': 'lz4', 'shuffle': 1}
68-
nbytes: 762.9M; nbytes_stored: 316; ratio: 2531645.6; initialized: 0/100
69-
store: builtins.dict
70-
7162
""" # flake8: noqa
7263

7364
def __init__(self, store, path=None, readonly=False):
74-
# N.B., expect at this point store is fully initialised with all
75-
# configuration metadata fully specified and normalised
65+
# N.B., expect at this point store is fully initialized with all
66+
# configuration metadata fully specified and normalized
7667

7768
self._store = store
7869
self._path = normalize_storage_path(path)
@@ -82,7 +73,7 @@ def __init__(self, store, path=None, readonly=False):
8273
self._key_prefix = ''
8374
self._readonly = readonly
8475

85-
# initialise metadata
76+
# initialize metadata
8677
try:
8778
mkey = self._key_prefix + array_meta_key
8879
meta_bytes = store[mkey]
@@ -101,7 +92,7 @@ def __init__(self, store, path=None, readonly=False):
10192
compressor_cls = get_compressor_cls(self._compression)
10293
self._compressor = compressor_cls(self._compression_opts)
10394

104-
# initialise attributes
95+
# initialize attributes
10596
akey = self._key_prefix + attrs_key
10697
self._attrs = Attributes(store, key=akey, readonly=readonly)
10798

@@ -120,12 +111,12 @@ def store(self):
120111

121112
@property
122113
def path(self):
123-
"""TODO doc me"""
114+
"""Storage path."""
124115
return self._path
125116

126117
@property
127118
def name(self):
128-
"""TODO doc me"""
119+
"""Array name following h5py convention."""
129120
if self.path:
130121
# follow h5py convention: add leading slash
131122
name = self.path
@@ -136,7 +127,7 @@ def name(self):
136127

137128
@property
138129
def readonly(self):
139-
"""A boolean, True if write operations are not permitted."""
130+
"""A boolean, True if modification operations are not permitted."""
140131
return self._readonly
141132

142133
@property

zarr/creation.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def create(shape, chunks, dtype=None, compression='default',
3131
Options to primary compressor. E.g., for blosc, provide a dictionary
3232
with keys 'cname', 'clevel' and 'shuffle'.
3333
fill_value : object
34-
Default value to use for uninitialised portions of the array.
34+
Default value to use for uninitialized portions of the array.
3535
order : {'C', 'F'}, optional
3636
Memory layout to be used within each chunk.
3737
store : MutableMapping, optional
@@ -64,7 +64,7 @@ def create(shape, chunks, dtype=None, compression='default',
6464
6565
""" # flake8: noqa
6666

67-
# initialise store
67+
# initialize store
6868
if store is None:
6969
store = dict()
7070
init_array(store, shape=shape, chunks=chunks, dtype=dtype,
@@ -105,7 +105,7 @@ def zeros(shape, chunks, dtype=None, compression='default',
105105
compression_opts=None, order='C', store=None, synchronizer=None,
106106
path=None, overwrite=False):
107107
"""Create an array, with zero being used as the default value for
108-
uninitialised portions of the array.
108+
uninitialized portions of the array.
109109
110110
For parameter definitions see :func:`zarr.creation.create`.
111111
@@ -135,7 +135,7 @@ def ones(shape, chunks, dtype=None, compression='default',
135135
compression_opts=None, order='C', store=None, synchronizer=None,
136136
path=None, overwrite=False):
137137
"""Create an array, with one being used as the default value for
138-
uninitialised portions of the array.
138+
uninitialized portions of the array.
139139
140140
For parameter definitions see :func:`zarr.creation.create`.
141141
@@ -164,7 +164,7 @@ def full(shape, chunks, fill_value, dtype=None, compression='default',
164164
compression_opts=None, order='C', store=None, synchronizer=None,
165165
path=None, overwrite=False):
166166
"""Create an array, with `fill_value` being used as the default value for
167-
uninitialised portions of the array.
167+
uninitialized portions of the array.
168168
169169
For parameter definitions see :func:`zarr.creation.create`.
170170
@@ -246,11 +246,11 @@ def array(data, chunks=None, dtype=None, compression='default',
246246
return z
247247

248248

249-
# noinspection PyShadowingBuiltins
250249
def open_array(path, mode='a', shape=None, chunks=None, dtype=None,
251250
compression='default', compression_opts=None, fill_value=0,
252251
order='C', synchronizer=None):
253-
"""Open an array stored in a directory on the file system.
252+
"""Convenience function to instantiate an array stored in a
253+
directory on the file system.
254254
255255
Parameters
256256
----------
@@ -274,7 +274,7 @@ def open_array(path, mode='a', shape=None, chunks=None, dtype=None,
274274
Options to primary compressor. E.g., for blosc, provide a dictionary
275275
with keys 'cname', 'clevel' and 'shuffle'.
276276
fill_value : object
277-
Default value to use for uninitialised portions of the array.
277+
Default value to use for uninitialized portions of the array.
278278
order : {'C', 'F'}, optional
279279
Memory layout to be used within each chunk.
280280
synchronizer : zarr.sync.ArraySynchronizer, optional
@@ -288,15 +288,15 @@ def open_array(path, mode='a', shape=None, chunks=None, dtype=None,
288288
--------
289289
>>> import numpy as np
290290
>>> import zarr
291-
>>> z1 = zarr.open('example.zarr', mode='w', shape=(10000, 10000),
292-
... chunks=(1000, 1000), fill_value=0)
291+
>>> z1 = zarr.open_array('example.zarr', mode='w', shape=(10000, 10000),
292+
... chunks=(1000, 1000), fill_value=0)
293293
>>> z1[:] = np.arange(100000000).reshape(10000, 10000)
294294
>>> z1
295295
zarr.core.Array((10000, 10000), float64, chunks=(1000, 1000), order=C)
296296
compression: blosc; compression_opts: {'clevel': 5, 'cname': 'lz4', 'shuffle': 1}
297297
nbytes: 762.9M; nbytes_stored: 24.8M; ratio: 30.8; initialized: 100/100
298298
store: zarr.storage.DirectoryStore
299-
>>> z2 = zarr.open('example.zarr', mode='r')
299+
>>> z2 = zarr.open_array('example.zarr', mode='r')
300300
>>> z2
301301
zarr.core.Array((10000, 10000), float64, chunks=(1000, 1000), order=C)
302302
compression: blosc; compression_opts: {'clevel': 5, 'cname': 'lz4', 'shuffle': 1}

0 commit comments

Comments
 (0)