Skip to content

Commit 214542c

Browse files
authored
Merge pull request #48 from bcdev/forman-rule_updates
Rule updates
2 parents 0dd9d85 + 810dfa5 commit 214542c

28 files changed

+952
-308
lines changed

CHANGES.md

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,32 @@
22

33
## Version 0.5.0 (in development)
44

5-
### Incompatible API changes:
5+
### Changes
66

7-
- Renamed nodes and node properties for consistency and clarity:
8-
- renamed `DataArrayNode` into `VariableNode`
9-
- renamed `DataArrayNode.data_array` into `VariableNode.array`
7+
- Rule `no-empty-chunks` has taken off the `"recommended"` settings
8+
as there is no easy/efficient way to tell whether a dataset has
9+
been written using `write_emtpy_chunks` option or not.
10+
The rule message itself has been fixed. (#45)
11+
12+
- Adjusted messages of rules `var-units` and `time-coordinate`
13+
to be consistent with messages of other rules.
14+
15+
- Core rule `dataset-title-attr` has been moved into `xcube` plugin
16+
and renamed to `xcube/dataset-title` because the core rule `var-descr`
17+
covers checking for dataset titles.
18+
19+
### Incompatible API changes
1020

1121
- Changed general use of term _verify_ into _validate_:
1222
- prefixed `RuleOp` methods by `validate_` for clarity.
1323
- renamed `XRLint.verify_datasets()` into `validate_files()`
1424
- renamed `Lint.verify_dataset()` into `validate()`
1525

16-
- Various changes for improved clarity and consistency
17-
regarding configuration management:
26+
- Renamed nodes and node properties for clarity and consistency:
27+
- renamed `DataArrayNode` into `VariableNode`
28+
- renamed `DataArrayNode.data_array` into `VariableNode.array`
29+
30+
- Various changes for improved clarity regarding configuration management:
1831
- introduced type aliases `ConfigLike` and `ConfigObjectLike`.
1932
- renamed `Config` into `ConfigObject`
2033
- renamed `ConfigList.configs` into `config_objects`
@@ -25,6 +38,10 @@
2538
- added class method `from_config()` to `ConfigList`.
2639
- removed function `xrlint.config.merge_configs` as it was no longer used.
2740

41+
### Other changes
42+
43+
- Added more tests so we finally reached 100% coverage.
44+
2845
## Version 0.4.1 (from 2025-01-31)
2946

3047
### Changes

docs/rule-ref.md

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,6 @@ Dimensions of data variables should have corresponding coordinates.
3232

3333
Contained in: `all`-:material-lightning-bolt: `recommended`-:material-lightning-bolt:
3434

35-
### :material-lightbulb: `dataset-title-attr`
36-
37-
Datasets should be given a non-empty title.
38-
39-
Contained in: `all`-:material-lightning-bolt: `recommended`-:material-alert:
40-
4135
### :material-bug: `grid-mappings`
4236

4337
Grid mappings, if any, shall have valid grid mapping coordinate variables.
@@ -69,7 +63,7 @@ Contained in: `all`-:material-lightning-bolt: `recommended`-:material-alert:
6963
Empty chunks should not be encoded and written. The rule currently applies to Zarr format only.
7064
[:material-information-variant:](https://docs.xarray.dev/en/stable/generated/xarray.Dataset.to_zarr.html#xarray-dataset-to-zarr)
7165

72-
Contained in: `all`-:material-lightning-bolt: `recommended`-:material-alert:
66+
Contained in: `all`-:material-lightning-bolt: `recommended`-:material-circle-off-outline:
7367

7468
### :material-bug: `time-coordinate`
7569

@@ -122,6 +116,13 @@ Spatial data variables should encode xcube color mappings in their metadata.
122116

123117
Contained in: `all`-:material-lightning-bolt: `recommended`-:material-alert:
124118

119+
### :material-bug: `dataset-title`
120+
121+
Datasets should be given a non-empty title.
122+
[:material-information-variant:](https://xcube.readthedocs.io/en/latest/cubespec.html#metadata)
123+
124+
Contained in: `all`-:material-lightning-bolt: `recommended`-:material-lightning-bolt:
125+
125126
### :material-lightbulb: `grid-mapping-naming`
126127

127128
Grid mapping variables should be called 'spatial_ref' or 'crs' for compatibility with rioxarray and other packages.

docs/todo.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424

2525
## Nice to have
2626

27-
- add some more tests so we reach 100% coverage
2827
- support `autofix` feature
2928
- support `md` (markdown) output format
3029
- support formatter op args/kwargs and apply validation schema

notebooks/mkdataset.py

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,28 @@
11
import numpy as np
22
import xarray as xr
33

4-
nx = 2
5-
ny = 3
6-
nt = 4
4+
nx = 720
5+
ny = 360
6+
nt = 5
7+
8+
ncx = 180
9+
ncy = 180
10+
nct = 1
711

812

913
def make_dataset() -> xr.Dataset:
1014
"""Create a dataset that passes xrlint core rules."""
1115

1216
return xr.Dataset(
13-
attrs=dict(title="SST-Climatology Subset"),
17+
attrs=dict(
18+
Conventions="CF-1.10",
19+
title="SST-Climatology Subset",
20+
history="2025-01-31 17:31:00 - created;",
21+
institution="BC",
22+
source="SST CCI L4",
23+
references="https://climate.esa.int/en/projects/sea-surface-temperature/",
24+
comment="Demo dataset",
25+
),
1426
coords={
1527
"x": xr.DataArray(
1628
np.linspace(-180, 180, nx),
@@ -53,15 +65,25 @@ def make_dataset() -> xr.Dataset:
5365
"sst": xr.DataArray(
5466
np.random.random((nt, ny, nx)),
5567
dims=["time", "y", "x"],
56-
attrs={"units": "kelvin", "grid_mapping": "spatial_ref"},
68+
attrs={
69+
"standard_name": "sea_surface_temperature",
70+
"long_name": "sea surface temperature",
71+
"units": "kelvin",
72+
"grid_mapping": "spatial_ref",
73+
},
5774
),
5875
"sst_anomaly": xr.DataArray(
5976
np.random.random((nt, ny, nx)),
6077
dims=["time", "y", "x"],
61-
attrs={"units": "kelvin", "grid_mapping": "spatial_ref"},
78+
attrs={
79+
"standard_name": "sea_surface_temperature_anomaly",
80+
"long_name": "sea surface temperature anomaly",
81+
"units": "kelvin",
82+
"grid_mapping": "spatial_ref",
83+
},
6284
),
6385
},
64-
)
86+
).chunk(time=nct, y=ncy, x=ncx)
6587

6688

6789
def make_dataset_with_issues() -> xr.Dataset:

0 commit comments

Comments
 (0)