-
-
Notifications
You must be signed in to change notification settings - Fork 282
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add hypothesis property tests #1746
Conversation
Hello @dcherian! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:
Comment last updated at 2024-04-05 17:47:12 UTC |
tests/test_properties.py
Outdated
elif path == "/": | ||
assert name is not None | ||
array_path = name | ||
array_name = "/" + name | ||
else: | ||
assert name is not None | ||
array_path = f"{path}/{name}" | ||
array_name = "/" + array_path |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
totally not obvious!
0a97842
to
42b88dc
Compare
1. Roundtrip a numpy array 2. Basic Indexing
This is important for zarr-developers#1931
This reverts commit 2ad1b35.
42b88dc
to
a772880
Compare
4e71735
to
bd90c6a
Compare
Some input needed:
|
src/zarr/strategies.py
Outdated
# TODO: clean this up | ||
if path is None and name is None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this mess be cleaned up?
* v3: (22 commits) [v3] `Buffer` ensure correct subclass based on the `BufferPrototype` argument (zarr-developers#1974) Fix doc build (zarr-developers#1987) Fix doc build warnings (zarr-developers#1985) Automatically generate API reference docs (zarr-developers#1918) Update `RemoteStore.__str__` and add UPath tests (zarr-developers#1964) [v3] Elevate codec pipeline (zarr-developers#1932) 0 dim arrays: indexing (zarr-developers#1980) `parse_shapelike` allows 0 (zarr-developers#1979) Clean up typing and docs for indexing (zarr-developers#1961) add json indentation to config (zarr-developers#1952) chore: update pre-commit hooks (zarr-developers#1973) Bump pypa/gh-action-pypi-publish in the actions group (zarr-developers#1969) chore: update pre-commit hooks (zarr-developers#1957) Update release.rst (zarr-developers#1960) doc: update release notes for 3.0.0.alpha (zarr-developers#1959) Basic working FsspecStore (zarr-developers#1785) Feature: Top level V3 API (zarr-developers#1884) Buffer Prototype Argument (zarr-developers#1910) Create issue-metrics.yml fixes bug in transpose (zarr-developers#1949) ...
* v3: Allow 'chunks' as an alias for 'chunk_shape' in array creation. (zarr-developers#1991)
* v3: (22 commits) chore: update pre-commit hooks (zarr-developers#2051) Apply ruff/flake8-bandit rule B006 (zarr-developers#2049) Move fixtures to `tests` (zarr-developers#1813) Multiple imports for an import name (zarr-developers#2047) Redundant list comprehension (zarr-developers#2048) chore: update pre-commit hooks (zarr-developers#2039) Cast fill value to array's dtype (zarr-developers#2020) chore: update pre-commit hooks (zarr-developers#2017) make shardingcodec pickleable (zarr-developers#2011) doc: copy 3.0.0.alpha changelog into release.rst (zarr-developers#2007) build(ci): enable python 3.12 in github actions (zarr-developers#2005) Bump NumPy to 2.0 (zarr-developers#1983) chore: update pre-commit hooks (zarr-developers#1989) Fix indexing with bools (zarr-developers#1968) Fix string interpolation (zarr-developers#1998) Unnecessary comprehension (zarr-developers#1997) Stop ignoring these ruff rules (zarr-developers#2001) Merge collapsible if statements (zarr-developers#1999) Unnecessary comprehension (zarr-developers#1996) Handle Path in `make_store_path` (zarr-developers#1992) ...
This looks like a real failure:
Apparently it is not roundtripping |
definitely! Given that I know nothing about hypothesis, how can I replicate this failure locally? |
This may be user error. It's sensitive to the import zarr
from zarr.array import Array
from zarr.group import Group
from zarr.store import MemoryStore
import numpy as np
store = MemoryStore(mode="w")
root = Group.create(store)
nparray = np.array([1], dtype=np.int8)
a = root.create_array(
"/0/0",
shape=nparray.shape,
chunks=(1,),
dtype=nparray.dtype.str,
attributes={},
# compressor=compressor, # TODO: FIXME
fill_value=nparray.dtype.type(0),
)
a[:] = nparray
print(a[:]) # [1]
store.close()
print(a[:]) # [0] |
I can replicate this locally. |
pre-commit.ci autofix |
After
mamba install hypothesis
Use
to see all the things it tries.
This was a quick attempt at a property test.
The other thing you can do is a "Stateful" test (e.g. https://github.com/pydata/xarray/blob/main/properties/test_index_manipulation.py)
which runs an arbitrary sequence of manipulations (e.g. add array, rename, move, delete, modify array, copy), and checks for consistency at each point.
cc @Zac-HD
TODO: