Skip to content

Commit 805a8df

Browse files
committed
format
1 parent a93ce00 commit 805a8df

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

src/zarr/core/array.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2218,7 +2218,7 @@ def __array__(
22182218
raise ValueError(msg)
22192219

22202220
arr_np = self[...]
2221-
if self.ndim==0:
2221+
if self.ndim == 0:
22222222
arr_np = np.array(arr_np)
22232223

22242224
if dtype is not None:

src/zarr/core/buffer/core.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,9 @@ def __setitem__(self, key: slice, value: Any) -> None:
138138
raise IndexError("Invalid index for scalar")
139139
self._value = value
140140

141-
def __array__(self, dtype: npt.DTypeLike | None = None, copy: bool | None = None
142-
) -> npt.NDArray[Any]:
141+
def __array__(
142+
self, dtype: npt.DTypeLike | None = None, copy: bool | None = None
143+
) -> npt.NDArray[Any]:
143144
return np.array(self._value, dtype=dtype, copy=copy)
144145

145146
def reshape(

tests/test_array.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
chunks_initialized,
3232
create_array,
3333
)
34-
from zarr.core.buffer import default_buffer_prototype, NDArrayLike
34+
from zarr.core.buffer import NDArrayLike, default_buffer_prototype
3535
from zarr.core.buffer.core import ScalarWrapper
3636
from zarr.core.buffer.cpu import NDBuffer
3737
from zarr.core.chunk_grids import _auto_partition
@@ -1257,6 +1257,7 @@ async def test_create_array_v2_no_shards(store: MemoryStore) -> None:
12571257
zarr_format=2,
12581258
)
12591259

1260+
12601261
@pytest.mark.parametrize("value", [1, 1.4, "a", b"a", np.array(1)])
12611262
def test_scalar_array(value: Any) -> None:
12621263
arr = zarr.array(value)
@@ -1282,7 +1283,7 @@ def test_scalar_array(value: Any) -> None:
12821283
assert x / 2 == value / 2
12831284
assert x // 2 == value // 2
12841285
assert x % 2 == value % 2
1285-
assert x ** 2 == value ** 2
1286+
assert x**2 == value**2
12861287
assert x == value
12871288
assert x != value + 1
12881289
assert bool(x) == bool(value)

0 commit comments

Comments
 (0)