Skip to content

Commit

Permalink
Fix the tests by forcing engine fastparquet
Browse files Browse the repository at this point in the history
  • Loading branch information
emfdavid committed Dec 18, 2024
1 parent 72f684e commit 14807de
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 28 deletions.
1 change: 0 additions & 1 deletion kerchunk/_grib_idx.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
""" # noqa: E501


import ujson
import itertools
import os
Expand Down
36 changes: 9 additions & 27 deletions tests/test__grib_idx.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,13 +248,8 @@ def test_build_idx_grib_mapping(self):
f"{mapping_fname}.idx_grib_mapping.parquet",
)
# Build the mapping from idx to cfgrib metadata and assert it matches the fixture
expected = pd.read_parquet(test_path)
pd.testing.assert_frame_equal(
mapping,
expected.assign(
step=lambda x: x.step.astype("timedelta64[ns]")
),
)
expected = pd.read_parquet(test_path, engine="fastparquet")
pd.testing.assert_frame_equal(mapping, expected)

# parse the idx files for 20231104 and compare the mapped result to the direct indexed result
test_name = fnames["20231104"]
Expand Down Expand Up @@ -289,11 +284,7 @@ def test_build_idx_grib_mapping(self):
"20231104",
f"{test_name}.kindex.parquet",
)
expected = pd.read_parquet(kindex_test_path)

expected = expected.assign(
step=lambda x: x.step.astype("timedelta64[ns]")
)
expected = pd.read_parquet(kindex_test_path, engine="fastparquet")

expected = expected.set_index(
["varname", "typeOfLevel", "stepType", "step", "level"]
Expand Down Expand Up @@ -393,13 +384,8 @@ def test_kerchunk_indexing(self):
TEST_DATE,
f"{fname}.kindex.parquet",
)
expected = pd.read_parquet(test_path)
pd.testing.assert_frame_equal(
kindex,
expected.assign(
step=lambda x: x.step.astype("timedelta64[ns]")
),
)
expected = pd.read_parquet(test_path, engine="fastparquet")
pd.testing.assert_frame_equal(kindex, expected)

@unittest.skip("TODO")
def test_extract_dataset_chunk_index(self):
Expand Down Expand Up @@ -444,10 +430,8 @@ def _test_index_extraction(self, sample_prefix: str):
test_path = os.path.join(
THIS_DIR, "grib_idx_fixtures", sample_prefix, "kerchunk_index.parquet"
)
expected = pd.read_parquet(test_path)
pd.testing.assert_frame_equal(
k_index, expected.assign(step=lambda x: x.step.astype("timedelta64[ns]"))
)
expected = pd.read_parquet(test_path, engine="fastparquet")
pd.testing.assert_frame_equal(k_index, expected)

def test_strip_datavar_chunks(self):
for sample_prefix, pre, post in [
Expand Down Expand Up @@ -583,7 +567,8 @@ def _reinflate_grib_store(
kind = pd.read_parquet(
os.path.join(
THIS_DIR, "grib_idx_fixtures", dataset, "test_reinflate.parquet"
)
),
engine="fastparquet",
)

zstore = reinflate_grib_store(
Expand Down Expand Up @@ -666,9 +651,6 @@ def _reinflate_grib_store(
with fsspec.open(test_path, "r") as f:
expected_keys = ujson.loads(f.read())

if key_set != expected_keys:
print("hello")

self.assertListEqual(key_set, expected_keys)

def test_reinflate_grib_store(self):
Expand Down

0 comments on commit 14807de

Please sign in to comment.