Skip to content

Commit cc2bd2b

Browse files
committed
use python code blocks in readme
1 parent 9098631 commit cc2bd2b

File tree

1 file changed

+21
-7
lines changed

1 file changed

+21
-7
lines changed

README.rst

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,9 @@ Design goals
4141
Usage
4242
-----
4343

44-
Create an array::
44+
Create an array
45+
46+
.. code-block:: python
4547
4648
>>> import numpy as np
4749
>>> import zarr
@@ -51,15 +53,19 @@ Create an array::
5153
cname: blosclz; clevel: 5; shuffle: 1 (BYTESHUFFLE)
5254
nbytes: 38.1M; cbytes: 0; initialized: 0/100
5355
54-
Fill it with some data::
56+
Fill it with some data
57+
58+
.. code-block:: python
5559
5660
>>> z[:] = np.arange(10000000, dtype='i4').reshape(10000, 1000)
5761
>>> z
5862
zarr.ext.SynchronizedArray((10000, 1000), int32, chunks=(1000, 100))
5963
cname: blosclz; clevel: 5; shuffle: 1 (BYTESHUFFLE)
6064
nbytes: 38.1M; cbytes: 2.0M; ratio: 19.3; initialized: 100/100
6165
62-
Obtain a NumPy array by slicing::
66+
Obtain a NumPy array by slicing
67+
68+
.. code-block:: python
6369
6470
>>> z[:]
6571
array([[ 0, 1, 2, ..., 997, 998, 999],
@@ -86,7 +92,9 @@ Obtain a NumPy array by slicing::
8692
[9998000, 9998001, 9998002, ..., 9998097, 9998098, 9998099],
8793
[9999000, 9999001, 9999002, ..., 9999097, 9999098, 9999099]], dtype=int32)
8894
89-
Resize the array and add more data::
95+
Resize the array and add more data
96+
97+
.. code-block:: python
9098
9199
>>> z.resize(20000, 1000)
92100
>>> z
@@ -100,7 +108,9 @@ Resize the array and add more data::
100108
nbytes: 76.3M; cbytes: 4.0M; ratio: 19.3; initialized: 200/200
101109
102110
For convenience, an ``append()`` method is also available, which can be used to
103-
append data to any axis::
111+
append data to any axis
112+
113+
.. code-block:: python
104114
105115
>>> a = np.arange(10000000, dtype='i4').reshape(10000, 1000)
106116
>>> z = zarr.array(a, chunks=(1000, 100))
@@ -119,7 +129,9 @@ append data to any axis::
119129
cname: blosclz; clevel: 5; shuffle: 1 (BYTESHUFFLE)
120130
nbytes: 152.6M; cbytes: 7.6M; ratio: 20.2; initialized: 400/400
121131
122-
Create a persistent array (data stored on disk)::
132+
Create a persistent array (data stored on disk)
133+
134+
.. code-block:: python
123135
124136
>>> path = 'example.zarr'
125137
>>> z = zarr.open(path, shape=(10000, 1000), dtype='i4', chunks=(1000, 100))
@@ -133,7 +145,9 @@ Create a persistent array (data stored on disk)::
133145
There is no need to close a persistent array. Data are automatically flushed
134146
to disk.
135147

136-
If you're working with really big arrays, try the 'lazy' option::
148+
If you're working with really big arrays, try the 'lazy' option
149+
150+
.. code-block:: python
137151
138152
>>> path = 'big.zarr'
139153
>>> z = zarr.open(path, shape=(1e8, 1e7), dtype='i4', chunks=(1000, 1000), lazy=True)

0 commit comments

Comments
 (0)