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

888 undo the suppressing of xarray chunking warning #918

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 0 additions & 4 deletions dfm_tools/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,3 @@
from dfm_tools import data
from dfm_tools.modelbuilder import *
from dfm_tools.observations import *

import warnings
# suppress chunks warning: https://github.com/Deltares/dfm_tools/issues/679
warnings.filterwarnings("ignore", category=UserWarning, message='The specified chunks separate the stored chunks along dimension "time" starting at index 1. This could degrade performance. Instead, consider rechunking after loading.')
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ dependencies = [
"netcdf4>=1.5.4",
#bottleneck<1.3.3 pip install fails in py39
"bottleneck>=1.3.3",
#xugrid<0.9.0 does not support partitioned 1d2d grids
"xugrid>=0.9.0",
#xugrid<0.11.0 does not use all meshkernel attrs (https://github.com/Deltares/xugrid/pull/250) and is not rechunking partitions (https://github.com/Deltares/xugrid/pull/253)
"xugrid>=0.11.0",
#cdsapi<0.7.0 supports credentials from environment variables
"cdsapi>=0.7.0",
#pydap<3.4.0 is from May 2017 and does not support newer python versions
Expand Down
20 changes: 9 additions & 11 deletions tests/test_external_packages.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,20 +149,18 @@ def test_xarray_decode_default_fillvals(tmp_path):
file_out = os.path.join(tmp_path, 'temp_fnc_default_fillvals_map.nc')
ds.to_netcdf(file_out)

# chunks=auto to avoid "UserWarning: The specified chunks separate the stored chunks along dimension "time" starting at index 1. This could degrade performance. Instead, consider rechunking after loading."
chunks = 'auto'

#open dataset with decode_fillvals
try:
uds = dfmt.open_partitioned_dataset(file_out,decode_fillvals=False)
except Exception as e:
# this raises "ValueError: connectivity contains negative values"
with pytest.raises(ValueError) as e:
# until xarray handles default fillvalues: https://github.com/Deltares/dfm_tools/issues/490
assert isinstance(e,ValueError)
if 'uds' in locals():
raise Exception("apparently xarray now decodes default fillvalues, so "
"`dfmt.decode_default_fillvals()` can be removed if minimum xarray "
"version is set as requirement")

# if xarray handles default fillvalues, `dfmt.decode_default_fillvals()` can be removed if minimum xarray version is set as requirement
uds = dfmt.open_partitioned_dataset(file_out, decode_fillvals=False, chunks=chunks)
assert "connectivity contains negative values" in str(e.value)

#this should be successful
uds2 = dfmt.open_partitioned_dataset(file_out,decode_fillvals=True)
uds2 = dfmt.open_partitioned_dataset(file_out, decode_fillvals=True, chunks=chunks)
fnc_new = uds2.grid.face_node_connectivity

assert fill_value_default in fnc_new
Expand Down
Loading