Skip to content

Commit 056398e

Browse files
committed
rollback deprecation
1 parent 4ab2698 commit 056398e

File tree

3 files changed

+18
-48
lines changed

3 files changed

+18
-48
lines changed

src/zarr/api/asynchronous.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ async def load(
244244

245245
obj = await open(store=store, path=path, zarr_format=zarr_format)
246246
if isinstance(obj, AsyncArray):
247-
return await obj.getitem(slice(None))
247+
return await obj.getitem(...)
248248
else:
249249
raise NotImplementedError("loading groups not yet supported")
250250

@@ -408,7 +408,7 @@ async def save_array(
408408
chunks=chunks,
409409
**kwargs,
410410
)
411-
await new.setitem(slice(None), arr)
411+
await new.setitem(..., arr)
412412

413413

414414
async def save_group(
@@ -520,7 +520,7 @@ async def array(
520520
z = await create(**kwargs)
521521

522522
# fill with data
523-
await z.setitem(slice(None), data)
523+
await z.setitem(..., data)
524524

525525
return z
526526

src/zarr/core/group.py

Lines changed: 10 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -295,36 +295,6 @@ def flatten(
295295
return metadata
296296

297297

298-
class ArraysProxy:
299-
"""
300-
Proxy for arrays in a group.
301-
302-
Used to implement the `Group.arrays` property
303-
"""
304-
305-
def __init__(self, group: Group) -> None:
306-
self._group = group
307-
308-
def __getitem__(self, key: str) -> Array:
309-
obj = self._group[key]
310-
if isinstance(obj, Array):
311-
return obj
312-
raise KeyError(key)
313-
314-
def __setitem__(self, key: str, value: npt.ArrayLike) -> None:
315-
"""
316-
Set an array in the group.
317-
"""
318-
self._group._sync(self._group._async_group.set_array(key, value))
319-
320-
def __iter__(self) -> Generator[tuple[str, Array], None]:
321-
for name, async_array in self._group._sync_iter(self._group._async_group.arrays()):
322-
yield name, Array(async_array)
323-
324-
def __call__(self) -> Generator[tuple[str, Array], None]:
325-
return iter(self)
326-
327-
328298
@dataclass(frozen=True)
329299
class GroupMetadata(Metadata):
330300
attributes: dict[str, Any] = field(default_factory=dict)
@@ -630,8 +600,10 @@ def from_dict(
630600
store_path=store_path,
631601
)
632602

633-
async def set_array(self, key: str, value: Any) -> None:
634-
"""fastpath for creating a new array
603+
async def setitem(self, key: str, value: Any) -> None:
604+
"""Fastpath for creating a new array
605+
606+
New arrays will be created with default array settings for the array type.
635607
636608
Parameters
637609
----------
@@ -1438,14 +1410,12 @@ def __iter__(self) -> Iterator[str]:
14381410
def __len__(self) -> int:
14391411
return self.nmembers()
14401412

1441-
@deprecated("Use Group.arrays setter instead.")
14421413
def __setitem__(self, key: str, value: Any) -> None:
1443-
"""Create a new array
1414+
"""Fastpath for creating a new array.
14441415
1445-
.. deprecated:: 3.0.0
1446-
Use Group.arrays.setter instead.
1416+
New arrays will be created using default settings for the array type.
14471417
"""
1448-
self._sync(self._async_group.set_array(key, value))
1418+
self._sync(self._async_group.setitem(key, value))
14491419

14501420
def __repr__(self) -> str:
14511421
return f"<Group {self.store_path}>"
@@ -1542,9 +1512,9 @@ def group_values(self) -> Generator[Group, None]:
15421512
for _, group in self.groups():
15431513
yield group
15441514

1545-
@property
1546-
def arrays(self) -> ArraysProxy:
1547-
return ArraysProxy(self)
1515+
def arrays(self) -> Generator[tuple[str, Array], None]:
1516+
for name, async_array in self._sync_iter(self._async_group.arrays()):
1517+
yield name, Array(async_array)
15481518

15491519
def array_keys(self) -> Generator[str, None]:
15501520
for name, _ in self.arrays():

tests/test_group.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -424,12 +424,12 @@ def test_group_len(store: Store, zarr_format: ZarrFormat) -> None:
424424

425425
def test_group_setitem(store: Store, zarr_format: ZarrFormat) -> None:
426426
"""
427-
Test the `Group.__setitem__` method.
427+
Test the `Group.__setitem__` method. (Deprecated)
428428
"""
429429
group = Group.from_store(store, zarr_format=zarr_format)
430430
arr = np.ones((2, 4))
431-
with pytest.warns(DeprecationWarning):
432-
group["key"] = arr
431+
group["key"] = arr
432+
assert list(group.array_keys()) == ["key"]
433433
assert group["key"].shape == (2, 4)
434434
np.testing.assert_array_equal(group["key"][:], arr)
435435

@@ -442,8 +442,8 @@ def test_group_setitem(store: Store, zarr_format: ZarrFormat) -> None:
442442

443443
# overwrite with another array
444444
arr = np.zeros((3, 5))
445-
with pytest.warns(DeprecationWarning):
446-
group[key] = arr
445+
group[key] = arr
446+
assert key in list(group.array_keys())
447447
assert group[key].shape == (3, 5)
448448
np.testing.assert_array_equal(group[key], arr)
449449

0 commit comments

Comments
 (0)