Skip to content

Commit

Permalink
DOC: Minor tweak to advanced indexing example in tutorial (#1550)
Browse files Browse the repository at this point in the history
* DOC: Update advanced indexing example.

Suggestion to modify the advanced indexing example so
that the indices and the values in the array differ.

* DOC: Fix malformed doctest comment.

* DOC: Rm reference to virtualenv from contributor guide.

---------

Co-authored-by: Davis Bennett <davis.v.bennett@gmail.com>
  • Loading branch information
rossbar and d-v-b committed Nov 24, 2023
1 parent 74764af commit b93860a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
6 changes: 3 additions & 3 deletions docs/contributing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,9 @@ Creating a development environment
To work with the Zarr source code, it is recommended to set up a Python virtual
environment and install all Zarr dependencies using the same versions as are used by
the core developers and continuous integration services. Assuming you have a Python
3 interpreter already installed, and have also installed the virtualenv package, and
you have cloned the Zarr source code and your current working directory is the root of
the repository, you can do something like the following::
3 interpreter already installed, and you have cloned the Zarr source code and your
current working directory is the root of the repository, you can do something like
the following::

$ mkdir -p ~/pyenv/zarr-dev
$ python -m venv ~/pyenv/zarr-dev
Expand Down
26 changes: 13 additions & 13 deletions docs/tutorial.rst
Original file line number Diff line number Diff line change
Expand Up @@ -480,17 +480,17 @@ Indexing with coordinate arrays
Items from a Zarr array can be extracted by providing an integer array of
coordinates. E.g.::

>>> z = zarr.array(np.arange(10))
>>> z = zarr.array(np.arange(10) ** 2)
>>> z[:]
array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
>>> z.get_coordinate_selection([1, 4])
array([1, 4])
array([ 0, 1, 4, 9, 16, 25, 36, 49, 64, 81])
>>> z.get_coordinate_selection([2, 5])
array([ 4, 25])

Coordinate arrays can also be used to update data, e.g.::

>>> z.set_coordinate_selection([1, 4], [-1, -2])
>>> z.set_coordinate_selection([2, 5], [-1, -2])
>>> z[:]
array([ 0, -1, 2, 3, -2, 5, 6, 7, 8, 9])
array([ 0, 1, -1, 9, 16, -2, 36, 49, 64, 81])

For multidimensional arrays, coordinates must be provided for each dimension,
e.g.::
Expand Down Expand Up @@ -534,17 +534,17 @@ Indexing with a mask array

Items can also be extracted by providing a Boolean mask. E.g.::

>>> z = zarr.array(np.arange(10))
>>> z = zarr.array(np.arange(10) ** 2)
>>> z[:]
array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
array([ 0, 1, 4, 9, 16, 25, 36, 49, 64, 81])
>>> sel = np.zeros_like(z, dtype=bool)
>>> sel[1] = True
>>> sel[4] = True
>>> sel[2] = True
>>> sel[5] = True
>>> z.get_mask_selection(sel)
array([1, 4])
array([ 4, 25])
>>> z.set_mask_selection(sel, [-1, -2])
>>> z[:]
array([ 0, -1, 2, 3, -2, 5, 6, 7, 8, 9])
array([ 0, 1, -1, 9, 16, -2, 36, 49, 64, 81])

Here's a multidimensional example::

Expand Down Expand Up @@ -986,7 +986,7 @@ It is also possible to initialize the filesystem outside of Zarr and then pass
it through. This requires creating an :class:`zarr.storage.FSStore` object
explicitly. For example::

>>> import s3fs * doctest: +SKIP
>>> import s3fs # doctest: +SKIP
>>> fs = s3fs.S3FileSystem(anon=True) # doctest: +SKIP
>>> store = zarr.storage.FSStore('/zarr-demo/store', fs=fs) # doctest: +SKIP
>>> g = zarr.open_group(store) # doctest: +SKIP
Expand Down

0 comments on commit b93860a

Please sign in to comment.