diff --git a/README.md b/README.md index 5cd8da4..d000168 100644 --- a/README.md +++ b/README.md @@ -145,12 +145,6 @@ if report.has_fails(): raise SystemExit("Dataset validation failed") ``` -The API also accepts the requested alias spelling: - -```python -report = validate_dataset(ds, time="forecast", space="grid", uncertaity="deterministic") -``` - ## Development Run tests: diff --git a/src/mlwp_data_specs/api.py b/src/mlwp_data_specs/api.py index d193d0f..06a1e90 100644 --- a/src/mlwp_data_specs/api.py +++ b/src/mlwp_data_specs/api.py @@ -127,10 +127,14 @@ def validate_dataset( time: Time | str | None = None, space: Space | str | None = None, uncertainty: Uncertainty | str | None = None, - uncertaity: Uncertainty | str | None = None, ) -> ValidationReport: """Validate a dataset against selected trait specifications. + If a trait is not explicitly provided as an argument, this function + will attempt to resolve it from the dataset's attributes (e.g., + ``mlwp_time_trait``, ``mlwp_space_trait``, ``mlwp_uncertainty_trait``). + If both are provided and differ, the argument takes precedence. + Parameters ---------- ds : xr.Dataset @@ -142,8 +146,6 @@ def validate_dataset( uncertainty : Uncertainty | str | None, optional Uncertainty trait profile (for example ``"deterministic"``, ``"ensemble"``, or ``"quantile"``). - uncertaity : Uncertainty | str | None, optional - Backward-compatible alias for ``uncertainty`` (spelling preserved). Returns ------- @@ -155,14 +157,9 @@ def validate_dataset( ValueError Raised when no traits are selected or when invalid trait values are provided. """ - if uncertainty is not None and uncertaity is not None: - raise ValueError("Provide only one of 'uncertainty' or 'uncertaity', not both") - - uncertainty_value = uncertainty if uncertainty is not None else uncertaity - time_trait = _resolve_trait(ds, time, Time) space_trait = _resolve_trait(ds, space, Space) - uncertainty_trait = _resolve_trait(ds, uncertainty_value, Uncertainty) + uncertainty_trait = _resolve_trait(ds, uncertainty, Uncertainty) if not any([time_trait, space_trait, uncertainty_trait]): raise ValueError("At least one trait must be selected") diff --git a/tests/test_api.py b/tests/test_api.py index abc4fb2..05dec0c 100644 --- a/tests/test_api.py +++ b/tests/test_api.py @@ -46,14 +46,6 @@ def test_validate_dataset_accepts_string_traits() -> None: assert not report.has_fails() -def test_validate_dataset_supports_uncertaity_alias() -> None: - """API accepts the spelled-as-requested uncertainty alias argument.""" - report = validate_dataset( - _forecast_grid_ds(), time="forecast", space="grid", uncertaity="deterministic" - ) - assert not report.has_fails() - - def test_validate_dataset_requires_trait() -> None: """API raises when no traits are selected.""" with pytest.raises(ValueError, match="At least one trait"):