Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added tests/btreev2.hdf5
Binary file not shown.
44 changes: 41 additions & 3 deletions tests/test_chunked.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
""" Test pyfive's abililty to read multidimensional datasets. """
import os

import h5py
import numpy as np
import pytest
from numpy.testing import assert_array_equal

import pyfive
Expand All @@ -10,11 +12,47 @@
DATASET_CHUNKED_HDF5_FILE = os.path.join(DIRNAME, "data", 'chunked.hdf5')


def test_chunked_dataset():
@pytest.fixture(scope='module')
def data():
return np.array(list(range(10_000)), dtype=np.int32).reshape((100, 100))

with pyfive.File(DATASET_CHUNKED_HDF5_FILE) as hfile:

@pytest.fixture(scope='module')
def name(data):
name = os.path.join(os.path.dirname(__file__), 'btreev2.hdf5')

with h5py.File(name, "w", libver="latest") as f:
# type 10 record - chunked without filters
f.create_dataset(
"btreev2",
data=data,
chunks=(10, 10),
maxshape=(None, None),
dtype="int32")

# type 11 record - chunked with filters
f.create_dataset(
"btreev2_filters",
data=data,
chunks=(10, 10),
maxshape=(None, None),
compression="gzip",
compression_opts=1,
fletcher32=True,
dtype="int32")

return name


def test_chunked_dataset():
with pyfive.File(DATASET_CHUNKED_HDF5_FILE) as hfile:
# check data
dset1 = hfile['dataset1']
assert_array_equal(dset1[:], np.arange(21*16).reshape((21, 16)))
assert_array_equal(dset1[:], np.arange(21 * 16).reshape((21, 16)))
assert dset1.chunks == (2, 2)

@pytest.mark.skip(reason="Not implemented yet, see https://github.com/NCAS-CMS/pyfive/issues/137")
def test_chunked_dataset_btreev2(name, data):
with pyfive.File(name) as hfile:
dset1 = hfile['btreev2']
assert_array_equal(dset1[...], data)
Loading