Skip to content
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Fixed

- Make checks on max spatial resolution (1km) more lenient using math.isclose [\#30](https://github.com/mlcast-community/mlcast-dataset-validator/pull/30), @ladc
- Detect Zarr v3 format from store files (`zarr.json`) instead of relying on `getattr(ds, "zarr_format", 2)` which always defaulted to v2, causing v3 stores to incorrectly fail the consolidated metadata check [\#27](https://github.com/mlcast-community/mlcast-dataset-validator/pull/27), @franchg

## [v0.2.0](https://github.com/mlcast-community/mlcast-dataset-validator/releases/tag/v0.2.0)
Expand Down
10 changes: 8 additions & 2 deletions mlcast_dataset_validator/checks/coords/spatial.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import math

import xarray as xr

from ...specs.reporting import ValidationReport, log_function_call
Expand Down Expand Up @@ -35,9 +37,13 @@ def check_spatial_requirements(
if len(x_vals) > 1 and len(y_vals) > 1:
x_res = abs(float(x_vals[1] - x_vals[0]))
y_res = abs(float(y_vals[1] - y_vals[0]))
max_resolution_m = max_resolution_km * 1000
if (
x_res <= max_resolution_km * 1000
and y_res <= max_resolution_km * 1000
x_res <= max_resolution_m
or math.isclose(x_res, max_resolution_m, rel_tol=1e-6)
) and (
y_res <= max_resolution_m
or math.isclose(y_res, max_resolution_m, rel_tol=1e-6)
):
report.add(
SECTION_ID,
Expand Down
Loading