-
Notifications
You must be signed in to change notification settings - Fork 18
Open
Labels
bugSomething isn't workingSomething isn't working
Description
What happened?
I noticed 4 tests in test_height_level_humidity.py were failing, depending on the used eccodes definition path.
================================================== short test summary info ==================================================
FAILED test_height_level_humidity.py::test_height_level_specific_humidity_to_relative_humidity_from_file - TypeError: '<' not supported between instances of 'str' and 'int'
FAILED test_height_level_humidity.py::test_relative_humidity_to_specific_humidity_from_file - TypeError: '<' not supported between instances of 'str' and 'int'
FAILED test_height_level_humidity.py::test_specific_humidity_to_dewpoint_from_file - TypeError: '<' not supported between instances of 'str' and 'int'
FAILED test_height_level_humidity.py::test_dewpoint_to_specific_humidity_from_file - TypeError: '<' not supported between instances of 'str' and 'int'
========================================== 4 failed, 8 passed, 1 warning in 4.23s ===========================================
I was wondering if it were possible to define these agnostic of the particular definition of shortnames.
What are the steps to reproduce the bug?
Run pytest using he following grib definitions: https://opendata.dwd.de/weather/lib/grib/eccodes_definitions.edzw-2.38.3-1.tar.bz2
Version
0.1.17
Platform (OS and architecture)
NA
Relevant log output
============================= test session starts ==============================
platform linux -- Python 3.11.11, pytest-8.4.2, pluggy-1.6.0 -- /shared/data/majacob/datasets/.venv/bin/python3
cachedir: .pytest_cache
rootdir: /shared/data/majacob/datasets/anemoi-transform
configfile: pyproject.toml
plugins: mock-3.15.1, xdist-3.8.0, skip-slow-0.0.5
collecting ... collected 1 item
test_height_level_humidity.py::test_dewpoint_to_specific_humidity_from_file FAILED [100%]
=================================== FAILURES ===================================
_________________ test_dewpoint_to_specific_humidity_from_file _________________
test_source = <function test_source.<locals>._source at 0x14c15fae6840>
@skip_if_offline
def test_dewpoint_to_specific_humidity_from_file(test_source):
source = test_source("anemoi-transform/filters/input_single_level_specific_humidity_to_relative_humidity.grib")
input_dewpoint_temperature = test_source(
"anemoi-transform/filters/single_level_dewpoint_temperature.npy"
).ds.to_numpy()
md = source.ds.sel(param="2d")[0].metadata()
ds = source.ds.sel(param=["2sh", "2t", "sp", "q", "t"])
ds += ekd.FieldList.from_array(input_dewpoint_temperature, md)
source.ds = ds
d_to_q_height = filter_registry.create(
"d_to_q_height",
height=2,
specific_humidity_at_height_level="2q",
dewpoint_temperature_at_height_level="2d",
surface_pressure="sp",
specific_humidity_at_model_levels="q",
temperature_at_model_levels="t",
model_level_AB=AB_coefficients_files,
)
pipeline = source | d_to_q_height
input_fields = collect_fields_by_param(source)
> output_fields = collect_fields_by_param(pipeline)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
test_height_level_humidity.py:523:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
utils/__init__.py:20: in collect_fields_by_param
for field in pipeline:
../src/anemoi/transform/workflow.py:28: in __iter__
return iter(self(None))
^^^^^^^^^^
../src/anemoi/transform/workflow.py:43: in __call__
return self.forward(data)
^^^^^^^^^^^^^^^^^^
../src/anemoi/transform/workflows/pipeline.py:47: in forward
data = filter.forward(data)
^^^^^^^^^^^^^^^^^^^^
../src/anemoi/transform/transform.py:203: in forward
return self.filter.backward(x)
^^^^^^^^^^^^^^^^^^^^^^^
../src/anemoi/transform/filters/matching.py:321: in backward
return self._transform(
../src/anemoi/transform/filters/matching.py:356: in _transform
for matching in grouping.iterate(data, other=result.append):
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <anemoi.transform.grouping.GroupByParamVertical object at 0x14c14a225f90>
data = MultiFieldList(MaskIndex(GRIBReader(/hpc/gtmp/majacob/.jtmp.gpnl101.20251023.141832.126848/pytest-of-majacob/pytest-16...ity_to_relative_humidity.grib),[0, 1, 2, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]),SimpleFieldList(1))
def iterate(self, data: list[Any], *, other: Callable[[Any], None] = _lost) -> Iterator[tuple[Any, ...]]:
"""Iterate over the data and group fields by parameters.
Parameters
----------
data : list of Any
List of data fields to group.
other : callable, optional
Function to call for fields that do not match the parameters, by default _lost.
Returns
-------
Iterator[Tuple[Any, ...]]
Iterator yielding tuples of grouped fields.
"""
self._get_groups(data, other=other)
for _, group in self.groups.items():
if len(group) != len(self.params):
for p in data:
print(p)
> raise ValueError(f"Missing component. Want {sorted(self.params)}, got {sorted(self.groups.keys())}")
^^^^^^^^^^^^^^^^^^^^^^^^^^
E TypeError: '<' not supported between instances of 'str' and 'int'
../src/anemoi/transform/grouping/__init__.py:115: TypeError
----------------------------- Captured stdout call -----------------------------
GribField(2sh,None,20220101,0,2,0)
GribField(sp,None,20220101,0,2,0)
GribField(2t,None,20220101,0,2,0)
GribField(t,130,20220101,0,2h,None)
GribField(q,130,20220101,0,2h,None)
GribField(t,131,20220101,0,2h,None)
GribField(q,131,20220101,0,2h,None)
GribField(t,132,20220101,0,2h,None)
GribField(q,132,20220101,0,2h,None)
GribField(t,133,20220101,0,2h,None)
GribField(q,133,20220101,0,2h,None)
GribField(t,134,20220101,0,2h,None)
GribField(q,134,20220101,0,2h,None)
GribField(t,135,20220101,0,2h,None)
GribField(q,135,20220101,0,2h,None)
GribField(t,136,20220101,0,2h,None)
GribField(q,136,20220101,0,2h,None)
GribField(t,137,20220101,0,2h,None)
GribField(q,137,20220101,0,2h,None)
ArrayField(2d,None,20220101,0,2,0)
----------------------------- Captured stderr call -----------------------------
input_single_level_specific_humidity_to_relative_humidity.grib: 0%| | 0.00/63.4M [00:00<?, ?B/s]
input_single_level_specific_humidity_to_relative_humidity.grib: 2%|▏ | 1.00M/63.4M [00:00<00:18, 3.49MB/s]
input_single_level_specific_humidity_to_relative_humidity.grib: 17%|█▋ | 11.0M/63.4M [00:00<00:01, 35.9MB/s]
input_single_level_specific_humidity_to_relative_humidity.grib: 36%|███▋ | 23.0M/63.4M [00:00<00:00, 62.7MB/s]
input_single_level_specific_humidity_to_relative_humidity.grib: 55%|█████▌ | 35.0M/63.4M [00:00<00:00, 80.2MB/s]
input_single_level_specific_humidity_to_relative_humidity.grib: 74%|███████▍ | 47.0M/63.4M [00:00<00:00, 91.9MB/s]
input_single_level_specific_humidity_to_relative_humidity.grib: 93%|█████████▎| 59.0M/63.4M [00:00<00:00, 99.8MB/s]
single_level_dewpoint_temperature.npy: 0%| | 0.00/12.7M [00:00<?, ?B/s]
single_level_dewpoint_temperature.npy: 8%|▊ | 1.00M/12.7M [00:00<00:03, 4.04MB/s]
single_level_dewpoint_temperature.npy: 79%|███████▉ | 10.0M/12.7M [00:00<00:00, 35.7MB/s]
------------------------------ Captured log call -------------------------------
WARNING anemoi.transform.filters.matching:matching.py:211 Some inputs will not be returned because filter direction is backward: {'specific_humidity_at_height_level'}
=============================== warnings summary ===============================
../../.venv/lib64/python3.11/site-packages/_pytest/config/__init__.py:833
/shared/data/majacob/datasets/.venv/lib64/python3.11/site-packages/_pytest/config/__init__.py:833: PytestAssertRewriteWarning: Module already imported so cannot be rewritten; anemoi.utils.testing
self.import_plugin(import_spec)
-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
=========================== short test summary info ============================
FAILED test_height_level_humidity.py::test_dewpoint_to_specific_humidity_from_file
========================= 1 failed, 1 warning in 2.69s =========================Accompanying data
No response
Organisation
DWD
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working
Type
Projects
Status
To be triaged