Skip to content

Commit 9c0d840

Browse files
committed
Revert "Fix is_total_slice for size-1 dimensions (#1800)"
This reverts commit 9d046ea.
1 parent cb4230d commit 9c0d840

File tree

3 files changed

+5
-20
lines changed

3 files changed

+5
-20
lines changed

docs/release.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ Unreleased
2525

2626
Enhancements
2727
~~~~~~~~~~~~
28+
* Revert "Performance improvement for reading and writing chunks if any of the dimensions is size 1."
29+
By :user:`Deepak Cherian <dcherian>`. :issue:`1874`.
30+
2831

2932
Docs
3033
~~~~

zarr/tests/test_util.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -89,15 +89,6 @@ def test_is_total_slice():
8989
assert not is_total_slice((slice(0, 50), slice(0, 50)), (100, 100))
9090
assert not is_total_slice((slice(0, 100, 2), slice(0, 100)), (100, 100))
9191

92-
# size-1 dimension edge-case
93-
# https://github.com/zarr-developers/zarr-python/issues/1730
94-
assert is_total_slice((slice(0, 1),), (1,))
95-
# this is an equivalent selection (without a slice)
96-
assert is_total_slice((0,), (1,))
97-
# same for multidimensional selection
98-
assert is_total_slice((slice(0, 1), slice(0, 10)), (1, 10))
99-
assert is_total_slice((0, slice(0, 10)), (1, 10))
100-
10192
with pytest.raises(TypeError):
10293
is_total_slice("foo", (100,))
10394

zarr/util.py

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -234,17 +234,8 @@ def is_total_slice(item, shape: Tuple[int]) -> bool:
234234
if isinstance(item, tuple):
235235
return all(
236236
(
237-
(
238-
isinstance(it, slice)
239-
and (
240-
(it == slice(None))
241-
or ((it.stop - it.start == sh) and (it.step in [1, None]))
242-
)
243-
)
244-
# The only scalar edge case, indexing with int 0 along a size-1 dimension
245-
# is identical to a total slice
246-
# https://github.com/zarr-developers/zarr-python/issues/1730
247-
or (isinstance(it, int) and it == 0 and sh == 1)
237+
isinstance(it, slice)
238+
and ((it == slice(None)) or ((it.stop - it.start == sh) and (it.step in [1, None])))
248239
)
249240
for it, sh in zip(item, shape)
250241
)

0 commit comments

Comments
 (0)