Skip to content

Commit 72f684e

Browse files
committed
Fix tests and black format
1 parent 261ee2f commit 72f684e

File tree

2 files changed

+24
-4
lines changed

2 files changed

+24
-4
lines changed

tests/test__grib_idx.py

+23-4
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
1717
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1818
"""
19+
1920
import copy
2021
import re
2122
import unittest
@@ -247,7 +248,13 @@ def test_build_idx_grib_mapping(self):
247248
f"{mapping_fname}.idx_grib_mapping.parquet",
248249
)
249250
# 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+
)
251258

252259
# parse the idx files for 20231104 and compare the mapped result to the direct indexed result
253260
test_name = fnames["20231104"]
@@ -284,6 +291,10 @@ def test_build_idx_grib_mapping(self):
284291
)
285292
expected = pd.read_parquet(kindex_test_path)
286293

294+
expected = expected.assign(
295+
step=lambda x: x.step.astype("timedelta64[ns]")
296+
)
297+
287298
expected = expected.set_index(
288299
["varname", "typeOfLevel", "stepType", "step", "level"]
289300
).sort_index()
@@ -382,7 +393,13 @@ def test_kerchunk_indexing(self):
382393
TEST_DATE,
383394
f"{fname}.kindex.parquet",
384395
)
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+
)
386403

387404
@unittest.skip("TODO")
388405
def test_extract_dataset_chunk_index(self):
@@ -428,7 +445,9 @@ def _test_index_extraction(self, sample_prefix: str):
428445
THIS_DIR, "grib_idx_fixtures", sample_prefix, "kerchunk_index.parquet"
429446
)
430447
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+
)
432451

433452
def test_strip_datavar_chunks(self):
434453
for sample_prefix, pre, post in [
@@ -587,7 +606,7 @@ def _reinflate_grib_store(
587606
with self.subTest(node_path=node.path):
588607

589608
match aggregation:
590-
case (AggregationType.HORIZON | AggregationType.BEST_AVAILABLE):
609+
case AggregationType.HORIZON | AggregationType.BEST_AVAILABLE:
591610

592611
self.assertEqual(node.time.dims, node.valid_time.dims)
593612
self.assertEqual(node.time.dims, node.step.dims)

tests/test_xarray_backend.py

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
format="NETCDF3_CLASSIC"
1313
)
1414

15+
1516
# Add parameterize test for storage formats (.json, .parquet)
1617
def test_reference_netcdf(m):
1718
m.pipe("data.nc3", bdata)

0 commit comments

Comments
 (0)