Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…into fix/runtime-order
  • Loading branch information
jhamman committed Oct 21, 2024
2 parents a8bda04 + 37fde7d commit db56a62
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 76 deletions.
72 changes: 0 additions & 72 deletions .github/workflows/codeql-analysis.yml

This file was deleted.

4 changes: 0 additions & 4 deletions .pep8speaks.yml

This file was deleted.

11 changes: 11 additions & 0 deletions src/zarr/core/group.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from typing_extensions import deprecated

import zarr.api.asynchronous as async_api
from zarr._compat import _deprecate_positional_args
from zarr.abc.metadata import Metadata
from zarr.abc.store import Store, set_or_delete
from zarr.core.array import Array, AsyncArray, _build_parents
Expand Down Expand Up @@ -1531,6 +1532,7 @@ def create(self, *args: Any, **kwargs: Any) -> Array:
# Backwards compatibility for 2.x
return self.create_array(*args, **kwargs)

@_deprecate_positional_args
def create_array(
self,
name: str,
Expand Down Expand Up @@ -1692,15 +1694,19 @@ def require_array(self, name: str, **kwargs: Any) -> Array:
"""
return Array(self._sync(self._async_group.require_array(name, **kwargs)))

@_deprecate_positional_args
def empty(self, *, name: str, shape: ChunkCoords, **kwargs: Any) -> Array:
return Array(self._sync(self._async_group.empty(name=name, shape=shape, **kwargs)))

@_deprecate_positional_args
def zeros(self, *, name: str, shape: ChunkCoords, **kwargs: Any) -> Array:
return Array(self._sync(self._async_group.zeros(name=name, shape=shape, **kwargs)))

@_deprecate_positional_args
def ones(self, *, name: str, shape: ChunkCoords, **kwargs: Any) -> Array:
return Array(self._sync(self._async_group.ones(name=name, shape=shape, **kwargs)))

@_deprecate_positional_args
def full(
self, *, name: str, shape: ChunkCoords, fill_value: Any | None, **kwargs: Any
) -> Array:
Expand All @@ -1710,22 +1716,27 @@ def full(
)
)

@_deprecate_positional_args
def empty_like(self, *, name: str, data: async_api.ArrayLike, **kwargs: Any) -> Array:
return Array(self._sync(self._async_group.empty_like(name=name, data=data, **kwargs)))

@_deprecate_positional_args
def zeros_like(self, *, name: str, data: async_api.ArrayLike, **kwargs: Any) -> Array:
return Array(self._sync(self._async_group.zeros_like(name=name, data=data, **kwargs)))

@_deprecate_positional_args
def ones_like(self, *, name: str, data: async_api.ArrayLike, **kwargs: Any) -> Array:
return Array(self._sync(self._async_group.ones_like(name=name, data=data, **kwargs)))

@_deprecate_positional_args
def full_like(self, *, name: str, data: async_api.ArrayLike, **kwargs: Any) -> Array:
return Array(self._sync(self._async_group.full_like(name=name, data=data, **kwargs)))

def move(self, source: str, dest: str) -> None:
return self._sync(self._async_group.move(source, dest))

@deprecated("Use Group.create_array instead.")
@_deprecate_positional_args
def array(
self,
name: str,
Expand Down
20 changes: 20 additions & 0 deletions tests/test_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -1334,3 +1334,23 @@ def test_update_attrs() -> None:
)
root.attrs["foo"] = "bar"
assert root.attrs["foo"] == "bar"


@pytest.mark.parametrize("method", ["empty", "zeros", "ones", "full"])
def test_group_deprecated_positional_args(method: str) -> None:
if method == "full":
kwargs = {"fill_value": 0}
else:
kwargs = {}

root = zarr.group()
with pytest.warns(FutureWarning, match=r"Pass name=.* as keyword args."):
arr = getattr(root, method)("foo", shape=1, **kwargs)
assert arr.shape == (1,)

method += "_like"
data = np.ones(1)

with pytest.warns(FutureWarning, match=r"Pass name=.*, data=.* as keyword args."):
arr = getattr(root, method)("foo_like", data, **kwargs)
assert arr.shape == data.shape

0 comments on commit db56a62

Please sign in to comment.