Skip to content

remove use of _deprecated_positional_args decorator #3093

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

Open
wants to merge 5 commits into
base: 3.1.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion .github/ISSUE_TEMPLATE/bug_report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,22 @@ body:
id: reproduce
attributes:
label: Steps to reproduce
description: Minimal, reproducible code sample, a copy-pastable example if possible.
description: Minimal, reproducible code sample. Must list dependencies in [inline script metadata](https://packaging.python.org/en/latest/specifications/inline-script-metadata/#example). When put in a file named `issue.py` calling `uv run issue.py` should show the issue.
value: |
```python
# /// script
# requires-python = ">=3.11"
# dependencies = [
# "zarr@git+https://github.com/zarr-developers/zarr-python.git@main",
# ]
# ///
#
# This script automatically imports the development branch of zarr to check for issues

import zarr
# your reproducer code
# zarr.print_debug_info()
```
validations:
required: true
- type: textarea
Expand Down
1 change: 1 addition & 0 deletions changes/3081.feature.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Adds ``fill_value`` to the list of attributes displayed in the output of the ``AsyncArray.info()`` method.
4 changes: 4 additions & 0 deletions docs/user-guide/arrays.rst
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ which can be used to print useful diagnostics, e.g.::
Type : Array
Zarr format : 3
Data type : DataType.int32
Fill value : 0
Shape : (10000, 10000)
Chunk shape : (1000, 1000)
Order : C
Expand All @@ -200,6 +201,7 @@ prints additional diagnostics, e.g.::
Type : Array
Zarr format : 3
Data type : DataType.int32
Fill value : 0
Shape : (10000, 10000)
Chunk shape : (1000, 1000)
Order : C
Expand Down Expand Up @@ -287,6 +289,7 @@ Here is an example using a delta filter with the Blosc compressor::
Type : Array
Zarr format : 3
Data type : DataType.int32
Fill value : 0
Shape : (10000, 10000)
Chunk shape : (1000, 1000)
Order : C
Expand Down Expand Up @@ -601,6 +604,7 @@ Sharded arrays can be created by providing the ``shards`` parameter to :func:`za
Type : Array
Zarr format : 3
Data type : DataType.uint8
Fill value : 0
Shape : (10000, 10000)
Shard shape : (1000, 1000)
Chunk shape : (100, 100)
Expand Down
2 changes: 2 additions & 0 deletions docs/user-guide/groups.rst
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ property. E.g.::
Type : Array
Zarr format : 3
Data type : DataType.int64
Fill value : 0
Shape : (1000000,)
Chunk shape : (100000,)
Order : C
Expand All @@ -145,6 +146,7 @@ property. E.g.::
Type : Array
Zarr format : 3
Data type : DataType.float32
Fill value : 0.0
Shape : (1000, 1000)
Chunk shape : (100, 100)
Order : C
Expand Down
3 changes: 3 additions & 0 deletions docs/user-guide/performance.rst
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ To use sharding, you need to specify the ``shards`` parameter when creating the
Type : Array
Zarr format : 3
Data type : DataType.uint8
Fill value : 0
Shape : (10000, 10000, 1000)
Shard shape : (1000, 1000, 1000)
Chunk shape : (100, 100, 100)
Expand Down Expand Up @@ -122,6 +123,7 @@ ratios, depending on the correlation structure within the data. E.g.::
Type : Array
Zarr format : 3
Data type : DataType.int32
Fill value : 0
Shape : (10000, 10000)
Chunk shape : (1000, 1000)
Order : C
Expand All @@ -141,6 +143,7 @@ ratios, depending on the correlation structure within the data. E.g.::
Type : Array
Zarr format : 3
Data type : DataType.int32
Fill value : 0
Shape : (10000, 10000)
Chunk shape : (1000, 1000)
Order : F
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -291,8 +291,8 @@ extend-exclude = [
extend-select = [
"ANN", # flake8-annotations
"B", # flake8-bugbear
"EXE", # flake8-executable
"C4", # flake8-comprehensions
"EXE", # flake8-executable
"FA", # flake8-future-annotations
"FLY", # flynt
"FURB", # refurb
Expand Down Expand Up @@ -364,14 +364,14 @@ module = [
"tests.test_store.test_local",
"tests.test_store.test_fsspec",
"tests.test_store.test_memory",
"tests.test_codecs.test_codecs",
]
strict = false

# TODO: Move the next modules up to the strict = false section
# and fix the errors
[[tool.mypy.overrides]]
module = [
"tests.test_codecs.test_codecs",
"tests.test_metadata.*",
"tests.test_store.test_core",
"tests.test_store.test_logging",
Expand Down
2 changes: 1 addition & 1 deletion src/zarr/api/asynchronous.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ async def open(
try:
metadata_dict = await get_array_metadata(store_path, zarr_format=zarr_format)
# TODO: remove this cast when we fix typing for array metadata dicts
_metadata_dict = cast(ArrayMetadataDict, metadata_dict)
_metadata_dict = cast("ArrayMetadataDict", metadata_dict)
# for v2, the above would already have raised an exception if not an array
zarr_format = _metadata_dict["zarr_format"]
is_v3_array = zarr_format == 3 and _metadata_dict.get("node_type") == "array"
Expand Down
5 changes: 0 additions & 5 deletions src/zarr/api/synchronous.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

import zarr.api.asynchronous as async_api
import zarr.core.array
from zarr._compat import _deprecate_positional_args
from zarr.core.array import Array, AsyncArray, CompressorLike
from zarr.core.group import Group
from zarr.core.sync import sync
Expand Down Expand Up @@ -154,7 +153,6 @@ def load(
)


@_deprecate_positional_args
def open(
store: StoreLike | None = None,
*,
Expand Down Expand Up @@ -248,7 +246,6 @@ def save(
)


@_deprecate_positional_args
def save_array(
store: StoreLike,
arr: NDArrayLike,
Expand Down Expand Up @@ -380,7 +377,6 @@ def array(data: npt.ArrayLike | Array, **kwargs: Any) -> Array:
return Array(sync(async_api.array(data=data, **kwargs)))


@_deprecate_positional_args
def group(
store: StoreLike | None = None,
*,
Expand Down Expand Up @@ -448,7 +444,6 @@ def group(
)


@_deprecate_positional_args
def open_group(
store: StoreLike | None = None,
*,
Expand Down
6 changes: 4 additions & 2 deletions src/zarr/codecs/crc32c_.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ async def _decode_single(
inner_bytes = data[:-4]

# Need to do a manual cast until https://github.com/numpy/numpy/issues/26783 is resolved
computed_checksum = np.uint32(crc32c(cast(typing_extensions.Buffer, inner_bytes))).tobytes()
computed_checksum = np.uint32(
crc32c(cast("typing_extensions.Buffer", inner_bytes))
).tobytes()
stored_checksum = bytes(crc32_bytes)
if computed_checksum != stored_checksum:
raise ValueError(
Expand All @@ -55,7 +57,7 @@ async def _encode_single(
) -> Buffer | None:
data = chunk_bytes.as_numpy_array()
# Calculate the checksum and "cast" it to a numpy array
checksum = np.array([crc32c(cast(typing_extensions.Buffer, data))], dtype=np.uint32)
checksum = np.array([crc32c(cast("typing_extensions.Buffer", data))], dtype=np.uint32)
# Append the checksum (as bytes) to the data
return chunk_spec.prototype.buffer.from_array_like(np.append(data, checksum.view("B")))

Expand Down
2 changes: 1 addition & 1 deletion src/zarr/codecs/sharding.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ class _ShardIndex(NamedTuple):
def chunks_per_shard(self) -> ChunkCoords:
result = tuple(self.offsets_and_lengths.shape[0:-1])
# The cast is required until https://github.com/numpy/numpy/pull/27211 is merged
return cast(ChunkCoords, result)
return cast("ChunkCoords", result)

def _localize_chunk(self, chunk_coords: ChunkCoords) -> ChunkCoords:
return tuple(
Expand Down
2 changes: 1 addition & 1 deletion src/zarr/codecs/transpose.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def parse_transpose_order(data: JSON | Iterable[int]) -> tuple[int, ...]:
raise TypeError(f"Expected an iterable. Got {data} instead.")
if not all(isinstance(a, int) for a in data):
raise TypeError(f"Expected an iterable of integers. Got {data} instead.")
return tuple(cast(Iterable[int], data))
return tuple(cast("Iterable[int]", data))


@dataclass(frozen=True)
Expand Down
4 changes: 3 additions & 1 deletion src/zarr/core/_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def byte_info(size: int) -> str:
return f"{size} ({human_readable_size(size)})"


@dataclasses.dataclass(kw_only=True)
@dataclasses.dataclass(kw_only=True, frozen=True, slots=True)
class ArrayInfo:
"""
Visual summary for an Array.
Expand All @@ -79,6 +79,7 @@ class ArrayInfo:
_type: Literal["Array"] = "Array"
_zarr_format: ZarrFormat
_data_type: np.dtype[Any] | DataType
_fill_value: object
_shape: tuple[int, ...]
_shard_shape: tuple[int, ...] | None = None
_chunk_shape: tuple[int, ...] | None = None
Expand All @@ -97,6 +98,7 @@ def __repr__(self) -> str:
Type : {_type}
Zarr format : {_zarr_format}
Data type : {_data_type}
Fill value : {_fill_value}
Shape : {_shape}""")

if self._shard_shape is not None:
Expand Down
Loading
Loading