Skip to content

Commit 908ad94

Browse files
Keep fill value for encoding (#369)
* Keep fill value for encoding * Add to release notes * Remove _FillValue from attributes in dmrpp _parse_variable * Slightly modify release notes * Pin icechunk for now and fix test * Pin zarr version to <2025.0.0 --------- Co-authored-by: Tom Nicholas <[email protected]>
1 parent bd010c4 commit 908ad94

File tree

6 files changed

+16
-8
lines changed

6 files changed

+16
-8
lines changed

ci/upstream.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ channels:
33
- conda-forge
44
- nodefaults
55
dependencies:
6-
- xarray>=2024.10.0
6+
- xarray>=2024.10.0,<2025.0.0
77
- h5netcdf
88
- h5py
99
- hdf5
@@ -28,6 +28,6 @@ dependencies:
2828
- fsspec
2929
- pip
3030
- pip:
31-
- icechunk>=0.1.0a8 # Installs zarr v3 as dependency
31+
- icechunk==0.1.0a8 # Installs zarr v3 beta 3 as dependency
3232
# - git+https://github.com/fsspec/kerchunk@main # kerchunk is currently incompatible with zarr-python v3 (https://github.com/fsspec/kerchunk/pull/516)
3333
- imagecodecs-numcodecs==2024.6.1

docs/releases.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ Bug fixes
3535

3636
- Fix bug preventing generating references for the root group of a file when a subgroup exists.
3737
(:issue:`336`, :pull:`338`) By `Tom Nicholas <https://github.com/TomNicholas>`_.
38+
- Fix bug in dmrpp reader so _FillValue is included in variables' encodings.
39+
(:pull:`369`) By `Aimee Barciauskas <https://github.com/abarciauskas-bgse>`_.
3840
- Fix bug passing arguments to FITS reader, and test it on Hubble Space Telescope data.
3941
(:pull:`363`) By `Tom Nicholas <https://github.com/TomNicholas>`_.
4042

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ classifiers = [
2121
requires-python = ">=3.10"
2222
dynamic = ["version"]
2323
dependencies = [
24-
"xarray>=2024.10.0",
24+
"xarray>=2024.10.0,<2025.0.0",
2525
"numpy>=2.0.0",
2626
"packaging",
2727
"universal-pathlib",
@@ -39,7 +39,7 @@ hdf_reader = [
3939
"numcodecs"
4040
]
4141
icechunk = [
42-
"icechunk>=0.1.0a8",
42+
"icechunk==0.1.0a8",
4343
]
4444
test = [
4545
"codecov",

virtualizarr/readers/dmrpp.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,8 @@ def _parse_variable(self, var_tag: ET.Element) -> Variable:
411411
attrs: dict[str, Any] = {}
412412
for attr_tag in var_tag.iterfind("dap:Attribute", self._NS):
413413
attrs.update(self._parse_attribute(attr_tag))
414-
# Fill value is placed in encoding and thus removed from attributes
414+
# Fill value is placed in zarr array's fill_value and variable encoding and removed from attributes
415+
encoding = {k: attrs.get(k) for k in self._ENCODING_KEYS if k in attrs}
415416
fill_value = attrs.pop("_FillValue", None)
416417
# create ManifestArray and ZArray
417418
zarray = ZArray(
@@ -423,7 +424,6 @@ def _parse_variable(self, var_tag: ET.Element) -> Variable:
423424
shape=shape,
424425
)
425426
marr = ManifestArray(zarray=zarray, chunkmanifest=chunkmanifest)
426-
encoding = {k: attrs.get(k) for k in self._ENCODING_KEYS if k in attrs}
427427
return Variable(dims=dims.keys(), data=marr, attrs=attrs, encoding=encoding)
428428

429429
def _parse_attribute(self, attr_tag: ET.Element) -> dict[str, Any]:

virtualizarr/tests/test_readers/test_dmrpp.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,11 @@ def test_parse_variable(tmp_path):
296296
assert var.shape == (720, 1440)
297297
assert var.data.zarray.chunks == (360, 720)
298298
assert var.data.zarray.fill_value == -32768
299-
assert var.encoding == {"add_offset": 298.15, "scale_factor": 0.001}
299+
assert var.encoding == {
300+
"add_offset": 298.15,
301+
"scale_factor": 0.001,
302+
"_FillValue": -32768,
303+
}
300304
assert var.attrs == {
301305
"long_name": "analysed sea surface temperature",
302306
"items": [1, 2, 3],

virtualizarr/tests/test_writers/test_icechunk.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -710,7 +710,9 @@ async def test_append_with_multiple_root_arrays(
710710
"time/c/0", prototype=default_buffer_prototype()
711711
)
712712
) == first_time_chunk_before_append
713-
new_ds = open_zarr(icechunk_filestore_append, consolidated=False, zarr_format=3)
713+
new_ds = open_zarr(
714+
icechunk_filestore_append.store, consolidated=False, zarr_format=3
715+
)
714716

715717
expected_ds1, expected_ds2 = open_dataset(filepath1), open_dataset(filepath2)
716718
expected_ds = concat([expected_ds1, expected_ds2], dim="time")

0 commit comments

Comments
 (0)