Skip to content

Add timerange constraint#399

Merged
bouweandela merged 2 commits intoClimate-REF:mainfrom
bouweandela:add-timerange-constraint
Sep 17, 2025
Merged

Add timerange constraint#399
bouweandela merged 2 commits intoClimate-REF:mainfrom
bouweandela:add-timerange-constraint

Conversation

@bouweandela
Copy link
Contributor

@bouweandela bouweandela commented Sep 11, 2025

Description

Add a timerange constraint. This will ensure the required data is available before attempting to run a diagnostic.

Requires #402

Checklist

Please confirm that this pull request has done the following:

  • Tests added
  • Documentation added (where applicable)
  • Changelog item added to changelog/

@bouweandela bouweandela force-pushed the add-timerange-constraint branch 2 times, most recently from 4ecd71e to 5e009cf Compare September 12, 2025 08:39
@bouweandela bouweandela force-pushed the add-timerange-constraint branch from 5e009cf to 6b30569 Compare September 12, 2025 10:12
@codecov
Copy link

codecov bot commented Sep 12, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.

Files with missing lines Coverage Δ
...imate-ref-core/src/climate_ref_core/constraints.py 96.13% <100.00%> (+1.82%) ⬆️
...ol/diagnostics/climate_at_global_warming_levels.py 100.00% <100.00%> (ø)
...esmvaltool/diagnostics/climate_drivers_for_fire.py 100.00% <ø> (ø)
..._esmvaltool/diagnostics/cloud_radiative_effects.py 100.00% <ø> (ø)
...e_ref_esmvaltool/diagnostics/cloud_scatterplots.py 100.00% <100.00%> (ø)
...valtool/diagnostics/regional_historical_changes.py 97.91% <100.00%> (+0.04%) ⬆️
...e_ref_esmvaltool/diagnostics/sea_ice_area_basic.py 100.00% <ø> (ø)
..._ref_esmvaltool/diagnostics/sea_ice_sensitivity.py 100.00% <ø> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@bouweandela bouweandela marked this pull request as ready for review September 12, 2025 10:56
Comment on lines +59 to +60
for dataset in datasets:
dataset["timerange"] = "1996/2014"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is likely to fix #400



@frozen
@total_ordering
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't know about this. Useful

def __repr__(self) -> str:
return f"{self.__class__.__name__}({', '.join(f'{a}={v}' for a, v in self._attrs.items())})"

def __eq__(self, other: object) -> bool:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we type hint that other should only be a `datetime.datetime?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only the specified fields are used for comparison.
"""

year: int | None = None
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
year: int | None = None
year: int

Should year be required? Is there a use case where you would skip fields, i.e. only specifying months?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, e.g selecting a season. Though the current implementation of the continuity check isn't smart enough for that.

@bouweandela bouweandela merged commit 2400784 into Climate-REF:main Sep 17, 2025
10 checks passed
@bouweandela bouweandela deleted the add-timerange-constraint branch September 17, 2025 07:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants