-
-
Notifications
You must be signed in to change notification settings - Fork 330
Ensure compressor=None results in no compression for V2 #2709
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
Changes from 5 commits
f10ba22
fac9e17
0dbe70a
1963647
fbc6a69
9625ca5
94f58bc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -7,11 +7,13 @@ | |||||
import pytest | ||||||
from numcodecs import Delta | ||||||
from numcodecs.blosc import Blosc | ||||||
from numcodecs.zstd import Zstd | ||||||
|
||||||
import zarr | ||||||
import zarr.core.buffer | ||||||
import zarr.storage | ||||||
from zarr import config | ||||||
from zarr.abc.store import Store | ||||||
from zarr.core.buffer.core import default_buffer_prototype | ||||||
from zarr.core.sync import sync | ||||||
from zarr.storage import MemoryStore, StorePath | ||||||
|
@@ -93,11 +95,7 @@ async def test_v2_encode_decode(dtype): | |||||
store = zarr.storage.MemoryStore() | ||||||
g = zarr.group(store=store, zarr_format=2) | ||||||
g.create_array( | ||||||
name="foo", | ||||||
shape=(3,), | ||||||
chunks=(3,), | ||||||
dtype=dtype, | ||||||
fill_value=b"X", | ||||||
name="foo", shape=(3,), chunks=(3,), dtype=dtype, fill_value=b"X", compressor=None | ||||||
) | ||||||
|
||||||
result = await store.get("foo/.zarray", zarr.core.buffer.default_buffer_prototype()) | ||||||
|
@@ -166,6 +164,29 @@ def test_v2_filters_codecs(filters: Any, order: Literal["C", "F"]) -> None: | |||||
np.testing.assert_array_equal(result, array_fixture) | ||||||
|
||||||
|
||||||
@pytest.mark.filterwarnings("ignore") | ||||||
@pytest.mark.parametrize("store", ["memory"], indirect=True) | ||||||
def test_create_array_defaults(store: Store): | ||||||
""" | ||||||
Test that passing compressor=None results in no compressor. Also test that the default value of the compressor | ||||||
parameter does produce a compressor. | ||||||
""" | ||||||
g = zarr.open(store, mode="w", zarr_format=2) | ||||||
arr = g.create_array("one", dtype="i8", shape=(1,), chunks=(1,), compressor=None) | ||||||
assert arr._async_array.compressor is None | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Does this work, too? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, but that's deprecated, apparently There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So should be |
||||||
assert not (arr.filters) | ||||||
arr = g.create_array("two", dtype="i8", shape=(1,), chunks=(1,)) | ||||||
assert arr._async_array.compressor is not None | ||||||
assert not (arr.filters) | ||||||
arr = g.create_array("three", dtype="i8", shape=(1,), chunks=(1,), compressor=Zstd()) | ||||||
assert arr._async_array.compressor is not None | ||||||
assert not (arr.filters) | ||||||
with pytest.raises(ValueError): | ||||||
g.create_array( | ||||||
"four", dtype="i8", shape=(1,), chunks=(1,), compressor=None, compressors=None | ||||||
) | ||||||
|
||||||
|
||||||
@pytest.mark.parametrize("array_order", ["C", "F"]) | ||||||
@pytest.mark.parametrize("data_order", ["C", "F"]) | ||||||
@pytest.mark.parametrize("memory_order", ["C", "F"]) | ||||||
|
Uh oh!
There was an error while loading. Please reload this page.