|
2 | 2 | import pathlib |
3 | 3 |
|
4 | 4 | import pytest |
| 5 | +import xarray |
5 | 6 |
|
6 | 7 | import emsarray |
7 | 8 | import emsarray.operations.cache |
|
12 | 13 | int_hash = '7b08e025e311c3dfcf5179b67c0fdc08e73de261' |
13 | 14 | attr_hash_lat = "2cb433979fc2d9c3884eea8569dd6a44406950f3" |
14 | 15 | cache_key_hash_cf1d_sha1 = "2b006999273225ed70d4810357b6a06e6bebe9a6" |
| 16 | +cache_key_hash_multifile_cf2d_sha1 = "ea2d2e6131f1e499f622e83ed4fc2415649def06" |
| 17 | +cache_key_hash_multifile_ugrid_mesh2d_sha1 = "1d72e01b159135208324ae9a643166f85aecba27" |
15 | 18 |
|
16 | 19 | # Blake2b |
17 | 20 | cache_key_hash_cf1d = "1a3226072f08441ee79f727b0775709209ff2965299539c898ecc401cf17e23f" |
@@ -200,3 +203,39 @@ def test_cache_key_cfgrid1d_sha1(datasets: pathlib.Path): |
200 | 203 | assert result_cache_key_cf is not None |
201 | 204 |
|
202 | 205 | assert result_cache_key_cf == cache_key_hash_cf1d_sha1 |
| 206 | + |
| 207 | + |
| 208 | +def test_cache_key_with_multifile_dataset_ugrid_mesh2d(datasets: pathlib.Path): |
| 209 | + |
| 210 | + ugrid_path1 = datasets / 'multifile_datasets/ugrid_mesh2d/ugrid_mesh2d_2024-01-01.nc' |
| 211 | + ugrid_path2 = datasets / 'multifile_datasets/ugrid_mesh2d/ugrid_mesh2d_2024-01-02.nc' |
| 212 | + |
| 213 | + dataset_paths = [ugrid_path1, ugrid_path2] |
| 214 | + |
| 215 | + multifile_dataset = xarray.open_mfdataset(dataset_paths, data_vars=['values']) |
| 216 | + |
| 217 | + multifile_ds_hash = hashlib.sha1() |
| 218 | + |
| 219 | + multifile_dataset.ems.hash_geometry(multifile_ds_hash) |
| 220 | + |
| 221 | + multifile_ds_digest = multifile_ds_hash.hexdigest() |
| 222 | + |
| 223 | + assert multifile_ds_digest == cache_key_hash_multifile_ugrid_mesh2d_sha1 |
| 224 | + |
| 225 | + |
| 226 | +def test_cache_key_with_multifile_dataset_cfgrid2d(datasets: pathlib.Path): |
| 227 | + |
| 228 | + cfgrid_path1 = datasets / 'multifile_datasets/cfgrid2d/cfgrid2d_2024-01-01.nc' |
| 229 | + cfgrid_path2 = datasets / 'multifile_datasets/cfgrid2d/cfgrid2d_2024-01-02.nc' |
| 230 | + |
| 231 | + dataset_paths = [cfgrid_path1, cfgrid_path2] |
| 232 | + |
| 233 | + multifile_dataset = xarray.open_mfdataset(dataset_paths, data_vars=['values']) |
| 234 | + |
| 235 | + multifile_ds_hash = hashlib.sha1() |
| 236 | + |
| 237 | + multifile_dataset.ems.hash_geometry(multifile_ds_hash) |
| 238 | + |
| 239 | + multifile_ds_digest = multifile_ds_hash.hexdigest() |
| 240 | + |
| 241 | + assert multifile_ds_digest == cache_key_hash_multifile_cf2d_sha1 |
0 commit comments