Skip to content

Commit 74fbd74

Browse files
authored
Allow tiny round-off exceedence of max_resolution in spatial check (#30)
1 parent 261e6b1 commit 74fbd74

2 files changed

Lines changed: 9 additions & 2 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99

1010
### Fixed
1111

12+
- Make checks on max spatial resolution (1km) more lenient using math.isclose [\#30](https://github.com/mlcast-community/mlcast-dataset-validator/pull/30), @ladc
1213
- 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
1314
- Fix for package version in ci build of html render of specs [\#25](https://github.com/mlcast-community/mlcast-dataset-validator/pull/25), @leifdenby
1415

mlcast_dataset_validator/checks/coords/spatial.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import math
2+
13
import xarray as xr
24

35
from ...specs.reporting import ValidationReport, log_function_call
@@ -35,9 +37,13 @@ def check_spatial_requirements(
3537
if len(x_vals) > 1 and len(y_vals) > 1:
3638
x_res = abs(float(x_vals[1] - x_vals[0]))
3739
y_res = abs(float(y_vals[1] - y_vals[0]))
40+
max_resolution_m = max_resolution_km * 1000
3841
if (
39-
x_res <= max_resolution_km * 1000
40-
and y_res <= max_resolution_km * 1000
42+
x_res <= max_resolution_m
43+
or math.isclose(x_res, max_resolution_m, rel_tol=1e-6)
44+
) and (
45+
y_res <= max_resolution_m
46+
or math.isclose(y_res, max_resolution_m, rel_tol=1e-6)
4147
):
4248
report.add(
4349
SECTION_ID,

0 commit comments

Comments
 (0)