Skip to content

Commit 9d5b41f

Browse files
committed
chore: add create_filters method to TestArray. Pop out compressor kwarg in create_array.
1 parent a1cb970 commit 9d5b41f

File tree

1 file changed

+10
-27
lines changed

1 file changed

+10
-27
lines changed

zarr/tests/test_core.py

Lines changed: 10 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,10 @@ def create_store(self) -> BaseStore:
8585
def create_chunk_store(self) -> Optional[BaseStore]:
8686
return None
8787

88-
def create_storage_transformers(self, shape) -> Tuple[Any, ...]:
88+
def create_storage_transformers(self, shape: Union[int, Tuple[int, ...]]) -> Tuple[Any, ...]:
89+
return ()
90+
91+
def create_filters(self, dtype: Optional[str]) -> Tuple[Any, ...]:
8992
return ()
9093

9194
def create_array(self, shape: Union[int, Tuple[int, ...]], **kwargs):
@@ -94,9 +97,10 @@ def create_array(self, shape: Union[int, Tuple[int, ...]], **kwargs):
9497
# keyword arguments for array initialization
9598
init_array_kwargs = {
9699
"path": kwargs.pop("path", self.path),
97-
"compressor": self.compressor,
100+
"compressor": kwargs.pop("compressor", self.compressor),
98101
"chunk_store": chunk_store,
99102
"storage_transformers": self.create_storage_transformers(shape),
103+
"filters": kwargs.pop("filters", self.create_filters(kwargs.get("dtype", None)))
100104
}
101105

102106
# keyword arguments for array instantiation
@@ -109,6 +113,7 @@ def create_array(self, shape: Union[int, Tuple[int, ...]], **kwargs):
109113
"partial_decompress": kwargs.pop("partial_decompress", self.partial_decompress),
110114
"write_empty_chunks": kwargs.pop("write_empty_chunks", self.write_empty_chunks),
111115
}
116+
112117
init_array(store, shape, **{**init_array_kwargs, **kwargs})
113118

114119
return Array(store, **access_array_kwargs)
@@ -2164,33 +2169,11 @@ class TestArrayWithFilters(TestArray):
21642169

21652170
compressor = Zlib(1)
21662171

2167-
def create_array(self, shape: Union[int, Tuple[int, ...]], **kwargs):
2168-
2169-
store = self.create_store()
2170-
chunk_store = self.create_chunk_store()
2171-
dtype = kwargs.get("dtype", None)
2172-
filters = [
2172+
def create_filters(self, dtype: Optional[str]) -> Tuple[Any, ...]:
2173+
return (
21732174
Delta(dtype=dtype),
21742175
FixedScaleOffset(dtype=dtype, scale=1, offset=0),
2175-
]
2176-
init_array_kwargs = {
2177-
"path": kwargs.pop("path", self.path),
2178-
"compressor": self.compressor,
2179-
"chunk_store": chunk_store,
2180-
"filters": filters,
2181-
}
2182-
2183-
access_array_kwargs = {
2184-
"path": init_array_kwargs["path"],
2185-
"read_only": kwargs.pop("read_only", self.read_only),
2186-
"chunk_store": chunk_store,
2187-
"cache_metadata": kwargs.pop("cache_metadata", self.cache_metadata),
2188-
"cache_attrs": kwargs.pop("cache_attrs", self.cache_attrs),
2189-
"write_empty_chunks": kwargs.pop("write_empty_chunks", self.write_empty_chunks),
2190-
}
2191-
init_array(store, shape, **{**init_array_kwargs, **kwargs})
2192-
2193-
return Array(store, **access_array_kwargs)
2176+
)
21942177

21952178
def expected(self):
21962179
return [

0 commit comments

Comments
 (0)