Skip to content
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

Add support for netCDF4.EnumType #8147

Merged
merged 45 commits into from
Jan 17, 2024
Merged
Changes from 1 commit
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
f1bc33b
ENH: make a light refactoring
Sep 12, 2023
4da8938
dirty commit
Sep 13, 2023
ab53970
Clean
Sep 13, 2023
75e00c7
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Sep 13, 2023
e1d51e3
wip: fix tests
Sep 13, 2023
95e30b2
dirty
Sep 15, 2023
a3160c5
clean
Sep 15, 2023
59ef686
Remove dict from valid attrs type
Sep 15, 2023
d135be2
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Sep 15, 2023
8c12e50
Fix encoding
Sep 15, 2023
e8f4872
FIX: ordering of flags
Sep 15, 2023
f481e1f
FIX: encoding of the same enum twice (or more).
Sep 18, 2023
951ea32
DOC: Add note for Enum on to_netcdf
Sep 22, 2023
ec3c90a
ENH: Raise explicit error on invalid variable
Nov 8, 2023
dcc1254
Merge remote-tracking branch 'xarray-origin/main' into enh/add-enum-s…
Nov 8, 2023
55927f1
DOC: Update whats-new
Nov 8, 2023
9e9c62c
fix: move enum check
Nov 8, 2023
5f1bffc
FIX: unit test for min-all-deps requirements
Nov 9, 2023
5189c74
Merge remote-tracking branch 'origin/main' into enh/add-enum-support
Nov 10, 2023
2410c2e
ENH: Add enum discovery
Nov 10, 2023
4b966ba
ENH: Raise error instead of modifying dataset
Nov 10, 2023
9273a1d
Merge remote-tracking branch 'origin/main' into enh/add-enum-support
Dec 11, 2023
cbfadad
Merge remote-tracking branch 'origin/main' into enh/add-enum-support
Jan 5, 2024
ca043a7
FIX: pop unnecessary encoding
Jan 5, 2024
ee3dc00
Add Enum Coder
Jan 8, 2024
892b2b6
Merge branch 'main' into enh/add-enum-support
kmuehlbauer Jan 9, 2024
9ab1ad1
DOC: Update what's new
Jan 9, 2024
7219b99
FIX: Use EnumMeta instead of EnumType fo py<3.11
Jan 9, 2024
2aa119f
ENH: Improve error message
Jan 9, 2024
da43a10
Remove unnecessary test
Jan 9, 2024
096f021
Update enum Coder
Jan 9, 2024
26bb8ce
ENH: Update error handling of decoding
Jan 9, 2024
d21d73a
ENH: Avoid encoding enum to CF
Jan 9, 2024
81a4bec
ENH: encode netcdf4 enum within dtype
Jan 10, 2024
b114ccc
MAINT: Remove CF flag_* encoding
Jan 10, 2024
6376a13
Add assertion after roundtrip in enum tests
Jan 10, 2024
89a8751
add NativeEnumCoder, adapt tests
kmuehlbauer Jan 11, 2024
ac20a40
remove test-file
kmuehlbauer Jan 11, 2024
d515e0d
restructure datatype extraction
kmuehlbauer Jan 11, 2024
5c66563
use invalid_netcdf for h5netcdf tests
kmuehlbauer Jan 11, 2024
d62ac29
FIX: encoding typing
Jan 11, 2024
f834ede
Update xarray/backends/netCDF4_.py
kmuehlbauer Jan 14, 2024
9a3980a
Merge branch 'main' into enh/add-enum-support
kmuehlbauer Jan 15, 2024
2a3103f
Merge branch 'main' into enh/add-enum-support
kmuehlbauer Jan 16, 2024
f22046d
Merge branch 'main' into enh/add-enum-support
kmuehlbauer Jan 17, 2024
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
Prev Previous commit
Next Next commit
Remove unnecessary test
  • Loading branch information
Abel Aoun committed Jan 9, 2024
commit da43a10f3044790c135b053cb82c395ca2bd0c19
22 changes: 0 additions & 22 deletions xarray/tests/test_backends.py
Original file line number Diff line number Diff line change
@@ -1726,28 +1726,6 @@ def test_encoding_enum__no_fill_value(self):
with create_tmp_file() as tmp_file2:
ds.to_netcdf(tmp_file2)
kmuehlbauer marked this conversation as resolved.
Show resolved Hide resolved

@requires_netCDF4
def test_encoding_enum__error_handling(self):
with create_tmp_file() as tmp_file:
cloud_type_dict = {"clear": 0, "cloudy": 1}
with nc4.Dataset(tmp_file, mode="w") as nc:
nc.createDimension("time", size=2)
cloud_type = nc.createEnumType("u1", "cloud_type", cloud_type_dict)
nc.createVariable(
"clouds",
cloud_type,
"time",
fill_value=255,
)
# v is filled with default fill_value of u1
with open_dataset(tmp_file, decode_enum=True) as ds:
with create_tmp_file() as tmp_file2:
with pytest.raises(
ValueError,
match=("trying to assign illegal value to Enum variable"),
):
ds.to_netcdf(tmp_file2)

@requires_netCDF4
def test_encoding_enum__multiple_variable_with_enum(self):
with create_tmp_file() as tmp_file: