Skip to content

Commit 418e8ec

Browse files
authored
Merge branch 'main' into 2694
2 parents a3f0a8a + b773b3e commit 418e8ec

File tree

8 files changed

+92
-26
lines changed

8 files changed

+92
-26
lines changed

.github/workflows/test.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,12 @@ jobs:
6060
hatch env run -e test.py${{ matrix.python-version }}-${{ matrix.numpy-version }}-${{ matrix.dependency-set }} list-env
6161
- name: Run Tests
6262
run: |
63-
hatch env run --env test.py${{ matrix.python-version }}-${{ matrix.numpy-version }}-${{ matrix.dependency-set }} run
63+
hatch env run --env test.py${{ matrix.python-version }}-${{ matrix.numpy-version }}-${{ matrix.dependency-set }} run-coverage
64+
- name: Upload coverage
65+
uses: codecov/codecov-action@v5
66+
with:
67+
token: ${{ secrets.CODECOV_TOKEN }}
68+
verbose: true # optional (default = false)
6469

6570
test-upstream-and-min-deps:
6671
name: py=${{ matrix.python-version }}-${{ matrix.dependency-set }}

codecov.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
coverage:
2+
status:
3+
patch:
4+
default:
5+
target: auto
6+
project:
7+
default:
8+
target: auto
9+
threshold: 0.1
10+
comment: false

docs/conf.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ def skip_submodules(
9191

9292
# General information about the project.
9393
project = "zarr"
94-
copyright = "2024, Zarr Developers"
94+
copyright = "2025, Zarr Developers"
9595
author = "Zarr Developers"
9696

9797
version = get_version("zarr")
@@ -181,6 +181,7 @@ def skip_submodules(
181181
],
182182
"collapse_navigation": True,
183183
"navigation_with_keys": False,
184+
"announcement": "Zarr-Python 3 is here! Check out the release announcement <a href='https://zarr.dev/blog/zarr-python-3-release/'>here.</a>",
184185
}
185186

186187
# Add any paths that contain custom themes here, relative to this directory.

docs/developers/contributing.rst

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -329,10 +329,16 @@ Release procedure
329329
Most of the release process is now handled by GitHub workflow which should
330330
automatically push a release to PyPI if a tag is pushed.
331331

332-
Before releasing, make sure that all pull requests which will be
333-
included in the release have been properly documented in
334-
`docs/release.rst`.
335-
332+
Pre-release
333+
"""""""""""
334+
1. Make sure that all pull requests which will be
335+
included in the release have been properly documented in
336+
:file:`docs/release-notes.rst`.
337+
2. Rename the "Unreleased" section heading in :file:`docs/release-notes.rst`
338+
to the version you are about to release.
339+
340+
Releasing
341+
"""""""""
336342
To make a new release, go to
337343
https://github.com/zarr-developers/zarr-python/releases and
338344
click "Draft a new release". Choose a version number prefixed
@@ -355,5 +361,8 @@ https://readthedocs.io. Full releases will be available under
355361
pre-releases will be available under
356362
`/latest <https://zarr.readthedocs.io/en/latest>`_.
357363

358-
Also review and merge the https://github.com/conda-forge/zarr-feedstock
359-
pull request that will be automatically generated.
364+
Post-release
365+
""""""""""""
366+
367+
- Review and merge the pull request on the `conda-forge feedstock <https://github.com/conda-forge/zarr-feedstock>`_ that will be automatically generated.
368+
- Create a new "Unreleased" section in the release notes

docs/release-notes.rst

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,19 @@
11
Release notes
22
=============
33

4+
Unreleased
5+
----------
6+
7+
New features
8+
~~~~~~~~~~~~
9+
10+
Bug fixes
11+
~~~~~~~~~
12+
* Fixes ``order`` argument for Zarr format 2 arrays (:issue:`2679`).
13+
14+
Behaviour changes
15+
~~~~~~~~~~~~~~~~~
16+
417
.. _release_3.0.0:
518

619
3.0.0

pyproject.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,13 +103,13 @@ Homepage = "https://github.com/zarr-developers/zarr-python"
103103
[tool.coverage.report]
104104
exclude_lines = [
105105
"pragma: no cover",
106+
"if TYPE_CHECKING:",
106107
"pragma: ${PY_MAJOR_VERSION} no cover",
107108
'.*\.\.\.' # Ignore "..." lines
108109
]
109110

110111
[tool.coverage.run]
111112
omit = [
112-
"src/zarr/meta_v1.py",
113113
"bench/compress_normal.py",
114114
]
115115

@@ -140,8 +140,8 @@ numpy = ["1.25", "2.1"]
140140
features = ["gpu"]
141141

142142
[tool.hatch.envs.test.scripts]
143-
run-coverage = "pytest --cov-config=pyproject.toml --cov=pkg --cov=src"
144-
run-coverage-gpu = "pip install cupy-cuda12x && pytest -m gpu --cov-config=pyproject.toml --cov=pkg --cov=src"
143+
run-coverage = "pytest --cov-config=pyproject.toml --cov=pkg --cov-report xml --cov=src --junitxml=junit.xml -o junit_family=legacy"
144+
run-coverage-gpu = "pip install cupy-cuda12x && pytest -m gpu --cov-config=pyproject.toml --cov=pkg --cov-report xml --cov=src --junitxml=junit.xml -o junit_family=legacy"
145145
run = "run-coverage --no-cov"
146146
run-verbose = "run-coverage --verbose"
147147
run-mypy = "mypy src"
@@ -170,7 +170,7 @@ numpy = ["1.25", "2.1"]
170170
version = ["minimal"]
171171

172172
[tool.hatch.envs.gputest.scripts]
173-
run-coverage = "pytest -m gpu --cov-config=pyproject.toml --cov=pkg --cov=src"
173+
run-coverage = "pytest -m gpu --cov-config=pyproject.toml --cov=pkg --cov-report xml --cov=src --junitxml=junit.xml -o junit_family=legacy"
174174
run = "run-coverage --no-cov"
175175
run-verbose = "run-coverage --verbose"
176176
run-mypy = "mypy src"

src/zarr/core/array.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import warnings
55
from asyncio import gather
66
from collections.abc import Iterable
7-
from dataclasses import dataclass, field
7+
from dataclasses import dataclass, field, replace
88
from itertools import starmap
99
from logging import getLogger
1010
from typing import (
@@ -1226,14 +1226,17 @@ async def _get_selection(
12261226
fill_value=self.metadata.fill_value,
12271227
)
12281228
if product(indexer.shape) > 0:
1229+
# need to use the order from the metadata for v2
1230+
_config = self._config
1231+
if self.metadata.zarr_format == 2:
1232+
_config = replace(_config, order=self.metadata.order)
1233+
12291234
# reading chunks and decoding them
12301235
await self.codec_pipeline.read(
12311236
[
12321237
(
12331238
self.store_path / self.metadata.encode_chunk_key(chunk_coords),
1234-
self.metadata.get_chunk_spec(
1235-
chunk_coords, self._config, prototype=prototype
1236-
),
1239+
self.metadata.get_chunk_spec(chunk_coords, _config, prototype=prototype),
12371240
chunk_selection,
12381241
out_selection,
12391242
)
@@ -1350,12 +1353,17 @@ async def _set_selection(
13501353
# Buffer and NDBuffer between components.
13511354
value_buffer = prototype.nd_buffer.from_ndarray_like(value)
13521355

1356+
# need to use the order from the metadata for v2
1357+
_config = self._config
1358+
if self.metadata.zarr_format == 2:
1359+
_config = replace(_config, order=self.metadata.order)
1360+
13531361
# merging with existing data and encoding chunks
13541362
await self.codec_pipeline.write(
13551363
[
13561364
(
13571365
self.store_path / self.metadata.encode_chunk_key(chunk_coords),
1358-
self.metadata.get_chunk_spec(chunk_coords, self._config, prototype),
1366+
self.metadata.get_chunk_spec(chunk_coords, _config, prototype),
13591367
chunk_selection,
13601368
out_selection,
13611369
)

tests/test_v2.py

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
import zarr.core.buffer
1313
import zarr.storage
1414
from zarr import config
15+
from zarr.core.buffer.core import default_buffer_prototype
16+
from zarr.core.sync import sync
1517
from zarr.storage import MemoryStore, StorePath
1618

1719

@@ -166,36 +168,54 @@ def test_v2_filters_codecs(filters: Any, order: Literal["C", "F"]) -> None:
166168

167169
@pytest.mark.parametrize("array_order", ["C", "F"])
168170
@pytest.mark.parametrize("data_order", ["C", "F"])
169-
def test_v2_non_contiguous(array_order: Literal["C", "F"], data_order: Literal["C", "F"]) -> None:
171+
@pytest.mark.parametrize("memory_order", ["C", "F"])
172+
def test_v2_non_contiguous(
173+
array_order: Literal["C", "F"], data_order: Literal["C", "F"], memory_order: Literal["C", "F"]
174+
) -> None:
175+
store = MemoryStore()
170176
arr = zarr.create_array(
171-
MemoryStore({}),
177+
store,
172178
shape=(10, 8),
173179
chunks=(3, 3),
174180
fill_value=np.nan,
175181
dtype="float64",
176182
zarr_format=2,
183+
filters=None,
184+
compressors=None,
177185
overwrite=True,
178186
order=array_order,
187+
config={"order": memory_order},
179188
)
180189

181190
# Non-contiguous write
182191
a = np.arange(arr.shape[0] * arr.shape[1]).reshape(arr.shape, order=data_order)
183-
arr[slice(6, 9, None), slice(3, 6, None)] = a[
184-
slice(6, 9, None), slice(3, 6, None)
185-
] # The slice on the RHS is important
192+
arr[6:9, 3:6] = a[6:9, 3:6] # The slice on the RHS is important
193+
np.testing.assert_array_equal(arr[6:9, 3:6], a[6:9, 3:6])
194+
186195
np.testing.assert_array_equal(
187-
arr[slice(6, 9, None), slice(3, 6, None)], a[slice(6, 9, None), slice(3, 6, None)]
196+
a[6:9, 3:6],
197+
np.frombuffer(
198+
sync(store.get("2.1", default_buffer_prototype())).to_bytes(), dtype="float64"
199+
).reshape((3, 3), order=array_order),
188200
)
201+
if memory_order == "F":
202+
assert (arr[6:9, 3:6]).flags.f_contiguous
203+
else:
204+
assert (arr[6:9, 3:6]).flags.c_contiguous
189205

206+
store = MemoryStore()
190207
arr = zarr.create_array(
191-
MemoryStore({}),
208+
store,
192209
shape=(10, 8),
193210
chunks=(3, 3),
194211
fill_value=np.nan,
195212
dtype="float64",
196213
zarr_format=2,
214+
compressors=None,
215+
filters=None,
197216
overwrite=True,
198217
order=array_order,
218+
config={"order": memory_order},
199219
)
200220

201221
# Contiguous write
@@ -204,8 +224,8 @@ def test_v2_non_contiguous(array_order: Literal["C", "F"], data_order: Literal["
204224
assert a.flags.f_contiguous
205225
else:
206226
assert a.flags.c_contiguous
207-
arr[slice(6, 9, None), slice(3, 6, None)] = a
208-
np.testing.assert_array_equal(arr[slice(6, 9, None), slice(3, 6, None)], a)
227+
arr[6:9, 3:6] = a
228+
np.testing.assert_array_equal(arr[6:9, 3:6], a)
209229

210230

211231
def test_default_compressor_deprecation_warning():

0 commit comments

Comments
 (0)