|
16 | 16 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
17 | 17 | OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
18 | 18 | """
|
| 19 | + |
19 | 20 | import copy
|
20 | 21 | import re
|
21 | 22 | import unittest
|
@@ -247,7 +248,13 @@ def test_build_idx_grib_mapping(self):
|
247 | 248 | f"{mapping_fname}.idx_grib_mapping.parquet",
|
248 | 249 | )
|
249 | 250 | # Build the mapping from idx to cfgrib metadata and assert it matches the fixture
|
250 |
| - pd.testing.assert_frame_equal(mapping, pd.read_parquet(test_path)) |
| 251 | + expected = pd.read_parquet(test_path) |
| 252 | + pd.testing.assert_frame_equal( |
| 253 | + mapping, |
| 254 | + expected.assign( |
| 255 | + step=lambda x: x.step.astype("timedelta64[ns]") |
| 256 | + ), |
| 257 | + ) |
251 | 258 |
|
252 | 259 | # parse the idx files for 20231104 and compare the mapped result to the direct indexed result
|
253 | 260 | test_name = fnames["20231104"]
|
@@ -284,6 +291,10 @@ def test_build_idx_grib_mapping(self):
|
284 | 291 | )
|
285 | 292 | expected = pd.read_parquet(kindex_test_path)
|
286 | 293 |
|
| 294 | + expected = expected.assign( |
| 295 | + step=lambda x: x.step.astype("timedelta64[ns]") |
| 296 | + ) |
| 297 | + |
287 | 298 | expected = expected.set_index(
|
288 | 299 | ["varname", "typeOfLevel", "stepType", "step", "level"]
|
289 | 300 | ).sort_index()
|
@@ -382,7 +393,13 @@ def test_kerchunk_indexing(self):
|
382 | 393 | TEST_DATE,
|
383 | 394 | f"{fname}.kindex.parquet",
|
384 | 395 | )
|
385 |
| - pd.testing.assert_frame_equal(kindex, pd.read_parquet(test_path)) |
| 396 | + expected = pd.read_parquet(test_path) |
| 397 | + pd.testing.assert_frame_equal( |
| 398 | + kindex, |
| 399 | + expected.assign( |
| 400 | + step=lambda x: x.step.astype("timedelta64[ns]") |
| 401 | + ), |
| 402 | + ) |
386 | 403 |
|
387 | 404 | @unittest.skip("TODO")
|
388 | 405 | def test_extract_dataset_chunk_index(self):
|
@@ -428,7 +445,9 @@ def _test_index_extraction(self, sample_prefix: str):
|
428 | 445 | THIS_DIR, "grib_idx_fixtures", sample_prefix, "kerchunk_index.parquet"
|
429 | 446 | )
|
430 | 447 | expected = pd.read_parquet(test_path)
|
431 |
| - pd.testing.assert_frame_equal(k_index, expected) |
| 448 | + pd.testing.assert_frame_equal( |
| 449 | + k_index, expected.assign(step=lambda x: x.step.astype("timedelta64[ns]")) |
| 450 | + ) |
432 | 451 |
|
433 | 452 | def test_strip_datavar_chunks(self):
|
434 | 453 | for sample_prefix, pre, post in [
|
@@ -587,7 +606,7 @@ def _reinflate_grib_store(
|
587 | 606 | with self.subTest(node_path=node.path):
|
588 | 607 |
|
589 | 608 | match aggregation:
|
590 |
| - case (AggregationType.HORIZON | AggregationType.BEST_AVAILABLE): |
| 609 | + case AggregationType.HORIZON | AggregationType.BEST_AVAILABLE: |
591 | 610 |
|
592 | 611 | self.assertEqual(node.time.dims, node.valid_time.dims)
|
593 | 612 | self.assertEqual(node.time.dims, node.step.dims)
|
|
0 commit comments