doc: tutorial updates for 3.0#2401
Closed
jhamman wants to merge 4 commits intozarr-developers:mainfrom
Closed
Conversation
jhamman
commented
Oct 18, 2024
| >>> compressor = Blosc(cname='zstd', clevel=3, shuffle=Blosc.BITSHUFFLE) | ||
| >>> data = np.arange(100000000, dtype='i4').reshape(10000, 10000) | ||
| >>> z = zarr.array(data, chunks=(1000, 1000), compressor=compressor) | ||
| >>> z = zarr.array(data, chunks=(1000, 1000), compressor=compressor, zarr_format=2) |
Member
Author
There was a problem hiding this comment.
This example works for zarr_format=2 but requires #2398 to work for zarr_format=3
| Groups can also contain arrays, e.g.:: | ||
|
|
||
| >>> z1 = bar.zeros('baz', shape=(10000, 10000), chunks=(1000, 1000), dtype='i4') | ||
| >>> z1 = bar.zeros(name='baz', shape=(10000, 10000), chunks=(1000, 1000), dtype='i4') |
Member
Author
There was a problem hiding this comment.
Suggested change
| >>> z1 = bar.zeros(name='baz', shape=(10000, 10000), chunks=(1000, 1000), dtype='i4') | |
| >>> z1 = bar.zeros('baz', shape=(10000, 10000), chunks=(1000, 1000), dtype='i4') |
see #2402
| Arrays can also be created with the ``create_array()`` and ``require_array()`` methods, e.g.:: | ||
|
|
||
| >>> z = bar.create_dataset('quux', shape=(10000, 10000), chunks=(1000, 1000), dtype='i4') | ||
| >>> z = bar.create_array(name='quux', shape=(10000, 10000), chunks=(1000, 1000), dtype='i4') |
Member
Author
There was a problem hiding this comment.
Suggested change
| >>> z = bar.create_array(name='quux', shape=(10000, 10000), chunks=(1000, 1000), dtype='i4') | |
| >>> z = bar.create_array('quux', shape=(10000, 10000), chunks=(1000, 1000), dtype='i4') |
see #2402
| <zarr.hierarchy.Group '/'> | ||
| >>> z = root.zeros('foo/bar/baz', shape=(10000, 10000), chunks=(1000, 1000), dtype='i4') | ||
| <Group file://data/group.zarr> | ||
| >>> z = root.zeros(name='foo/bar/baz', shape=(10000, 10000), chunks=(1000, 1000), dtype='i4') |
Member
Author
There was a problem hiding this comment.
Suggested change
| >>> z = root.zeros(name='foo/bar/baz', shape=(10000, 10000), chunks=(1000, 1000), dtype='i4') | |
| >>> z = root.zeros('foo/bar/baz', shape=(10000, 10000), chunks=(1000, 1000), dtype='i4') |
| >>> root = zarr.group() | ||
| >>> foo = root.create_group('foo') | ||
| >>> bar = foo.zeros('bar', shape=1000000, chunks=100000, dtype='i8') | ||
| >>> bar = foo.zeros(name='bar', shape=1000000, chunks=100000, dtype='i8') |
Member
Author
There was a problem hiding this comment.
Suggested change
| >>> bar = foo.zeros(name='bar', shape=1000000, chunks=100000, dtype='i8') | |
| >>> bar = foo.zeros('bar', shape=1000000, chunks=100000, dtype='i8') |
| >>> bar = foo.zeros(name='bar', shape=1000000, chunks=100000, dtype='i8') | ||
| >>> bar[:] = 42 | ||
| >>> baz = foo.zeros('baz', shape=(1000, 1000), chunks=(100, 100), dtype='f4') | ||
| >>> baz = foo.zeros(name='baz', shape=(1000, 1000), chunks=(100, 100), dtype='f4') |
Member
Author
There was a problem hiding this comment.
Suggested change
| >>> baz = foo.zeros(name='baz', shape=(1000, 1000), chunks=(100, 100), dtype='f4') | |
| >>> baz = foo.zeros('baz', shape=(1000, 1000), chunks=(100, 100), dtype='f4') |
| >>> root = zarr.group() | ||
| >>> root.attrs['foo'] = 'bar' | ||
| >>> z = root.zeros('zzz', shape=(10000, 10000)) | ||
| >>> z = root.zeros(name='zzz', shape=(10000, 10000)) |
Member
Author
There was a problem hiding this comment.
Suggested change
| >>> z = root.zeros(name='zzz', shape=(10000, 10000)) | |
| >>> z = root.zeros('zzz', shape=(10000, 10000)) |
| arrays, as long as the units are specified. E.g.:: | ||
|
|
||
| >>> z = zarr.array(['2007-07-13', '2006-01-13', '2010-08-13'], dtype='M8[D]') | ||
| >>> z = zarr.array(['2007-07-13', '2006-01-13', '2010-08-13'], dtype='M8[D]', zarr_format=2) |
Member
Author
There was a problem hiding this comment.
Add note above explaining that datetimes/timedeltas are only supported by v2 data format for now.
Contributor
|
Woop woop! In case you don't know about it already, https://github.com/scientific-python/pytest-doctestplus?tab=readme-ov-file#fixing-existing-docstrings might be helpful |
Member
Author
|
closing in favor of #2589 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is a work in progress. Running through the tutorial helped identify a number of issues that we likely want to address before we release 3.0.
TODO: