Skip to content

Commit

Permalink
group: the meta_array argument is now used for new arrays
Browse files Browse the repository at this point in the history
  • Loading branch information
madsbk committed Jan 12, 2022
1 parent 287ab92 commit 25cacb1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
10 changes: 6 additions & 4 deletions zarr/hierarchy.py
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ def typestr(o):

def __getstate__(self):
return (self._store, self._path, self._read_only, self._chunk_store,
self.attrs.cache, self._synchronizer)
self.attrs.cache, self._synchronizer, self._meta_array)

def __setstate__(self, state):
self.__init__(*state)
Expand Down Expand Up @@ -371,11 +371,12 @@ def __getitem__(self, item):
if contains_array(self._store, path):
return Array(self._store, read_only=self._read_only, path=path,
chunk_store=self._chunk_store,
synchronizer=self._synchronizer, cache_attrs=self.attrs.cache)
synchronizer=self._synchronizer, cache_attrs=self.attrs.cache,
meta_array=self._meta_array)
elif contains_group(self._store, path):
return Group(self._store, read_only=self._read_only, path=path,
chunk_store=self._chunk_store, cache_attrs=self.attrs.cache,
synchronizer=self._synchronizer)
synchronizer=self._synchronizer, meta_array=self._meta_array)
else:
raise KeyError(item)

Expand Down Expand Up @@ -898,7 +899,8 @@ def _require_dataset_nosync(self, name, shape, dtype=None, exact=False,
cache_attrs = kwargs.get('cache_attrs', self.attrs.cache)
a = Array(self._store, path=path, read_only=self._read_only,
chunk_store=self._chunk_store, synchronizer=synchronizer,
cache_metadata=cache_metadata, cache_attrs=cache_attrs)
cache_metadata=cache_metadata, cache_attrs=cache_attrs,
meta_array=self._meta_array)
shape = normalize_shape(shape)
if shape != a.shape:
raise TypeError('shape do not match existing array; expected {}, got {}'
Expand Down
1 change: 1 addition & 0 deletions zarr/tests/test_cupy.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,4 +135,5 @@ def test_group(tmp_path, compressor, store_type):
assert a.shape == (10, 11)
assert a.dtype == int
assert isinstance(a, Array)
assert isinstance(a[:], cupy.ndarray)
assert (a[:] == 1).all()

0 comments on commit 25cacb1

Please sign in to comment.