Skip to content

Commit

Permalink
QA
Browse files Browse the repository at this point in the history
  • Loading branch information
EddyCMWF committed Jun 21, 2024
1 parent c8c415d commit 0ec25c0
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 7 deletions.
6 changes: 3 additions & 3 deletions cfgrib/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -332,9 +332,9 @@ def get_values_in_order(message, shape):
class OnDiskArray:
index: abc.Index[T.Any, abc.Field]
shape: T.Tuple[int, ...]
field_id_index: T.Dict[
T.Tuple[T.Any, ...], T.List[T.Union[int, T.Tuple[int, int]]]
] = attr.attrib(repr=False)
field_id_index: T.Dict[T.Tuple[T.Any, ...], T.List[T.Union[int, T.Tuple[int, int]]]] = (
attr.attrib(repr=False)
)
missing_value: float
geo_ndim: int = attr.attrib(default=1, repr=False)
dtype = np.dtype("float32")
Expand Down
Binary file added tests/sample-data/era5-levels-members.nc
Binary file not shown.
3 changes: 2 additions & 1 deletion tests/test_30_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,12 +310,13 @@ def test_open_file() -> None:
assert "t" in res.variables
assert "z" in res.variables


def test_open_file_filter_by_keys_list() -> None:
res = dataset.open_file(TEST_DATA, filter_by_keys={"shortName": "t"})

assert "t" in res.variables
assert "z" not in res.variables

res = dataset.open_file(TEST_DATA_MULTI_PARAMS)

assert "t" in res.variables
Expand Down
9 changes: 6 additions & 3 deletions tests/test_50_xarray_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,20 +37,23 @@ def test_xr_open_dataset_file_filter_by_keys() -> None:
assert "z" in ds.data_vars
assert "u" in ds.data_vars

ds = xr.open_dataset(TEST_DATA_MULTI_PARAMS, engine="cfgrib", filter_by_keys={"shortName": "t"})
ds = xr.open_dataset(
TEST_DATA_MULTI_PARAMS, engine="cfgrib", filter_by_keys={"shortName": "t"}
)

assert "t" in ds.data_vars
assert "z" not in ds.data_vars
assert "u" not in ds.data_vars

ds = xr.open_dataset(TEST_DATA_MULTI_PARAMS, engine="cfgrib", filter_by_keys={"shortName": ["t", "z"]})
ds = xr.open_dataset(
TEST_DATA_MULTI_PARAMS, engine="cfgrib", filter_by_keys={"shortName": ["t", "z"]}
)

assert "t" in ds.data_vars
assert "z" in ds.data_vars
assert "u" not in ds.data_vars



def test_xr_open_dataset_dict() -> None:
fieldset = {
-10: {
Expand Down

0 comments on commit 0ec25c0

Please sign in to comment.