Skip to content

Commit

Permalink
fix test for windows
Browse files Browse the repository at this point in the history
  • Loading branch information
boeddeker committed Jun 17, 2024
1 parent ea516b0 commit 9ddc9a7
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions tests/io_tests/test_hdf5.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,24 @@
from paderbox.io import dump_hdf5, load_hdf5
import packaging.version

# numpy default integer type on Windows is int32 for numpy 1
# In numpy 2 they changed it to int64 to match unix and mac.
_default_np_int = (
np.int32
if os.name == 'nt'
and packaging.version.parse(np.__version__) < packaging.version.parse('2')
else
np.int64
)

class TestHdf5:
@pytest.mark.parametrize("name,data,expect", [
('int', {'key': 1}, (
np.int32(1) if os.name == 'nt' and packaging.version.parse(np.__version__) < packaging.version.parse('2') else np.int64(1)
)), # numpy default integer type on Windows is int32 for numpy 1 and int64 for numpy 2 (unix and mac always int64).
('int', {'key': 1}, _default_np_int(1)),
('float', {'key': 1.1}, np.float64(1.1)),
('complex', {'key': 1.1j}, np.complex128(1.1j)),
('str', {'key': 'bla'}, 'bla'),
('none', {'key': None}, None),
('np int', {'key': int(1)}, np.int32(1) if os.name == 'nt' else np.int64(1)),
('np int', {'key': int(1)}, _default_np_int(1)),
('np float32', {'key': np.float32(1.1)}, np.float32(1.1)),
('np float64', {'key': np.float64(1.1)}, np.float64(1.1)),
('np complex64', {'key': np.complex64(1.1j)}, np.complex64(1.1j)),
Expand Down

0 comments on commit 9ddc9a7

Please sign in to comment.