Skip to content

Commit 1027d46

Browse files
committed
Include NaT values in tests
Make sure that we are able to encode NaT values without issues by introducing `-0`s in our test data.
1 parent 45fe8bf commit 1027d46

File tree

7 files changed

+28
-28
lines changed

7 files changed

+28
-28
lines changed

numcodecs/tests/test_blosc.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,10 @@
4343
np.random.normal(loc=1000, scale=1, size=(100, 10)),
4444
np.random.randint(0, 2, size=1000, dtype=bool).reshape(100, 10, order='F'),
4545
np.random.choice([b'a', b'bb', b'ccc'], size=1000).reshape(10, 10, 10),
46-
np.random.randint(0, 2**60, size=1000, dtype='u8').view('M8[ns]'),
47-
np.random.randint(0, 2**60, size=1000, dtype='u8').view('m8[ns]'),
48-
np.random.randint(0, 2**25, size=1000, dtype='u8').view('M8[m]'),
49-
np.random.randint(0, 2**25, size=1000, dtype='u8').view('m8[m]'),
46+
(-np.random.randint(-2**30, 2**30, size=1000, dtype='i8')).view('M8[ns]'),
47+
(-np.random.randint(-2**30, 2**30, size=1000, dtype='i8')).view('m8[ns]'),
48+
(-np.random.randint(-2**12, 2**13, size=1000, dtype='i8')).view('M8[m]'),
49+
(-np.random.randint(-2**12, 2**13, size=1000, dtype='i8')).view('m8[m]'),
5050
]
5151

5252

numcodecs/tests/test_bz2.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@
3030
np.random.normal(loc=1000, scale=1, size=(100, 10)),
3131
np.random.randint(0, 2, size=1000, dtype=bool).reshape(100, 10, order='F'),
3232
np.random.choice([b'a', b'bb', b'ccc'], size=1000).reshape(10, 10, 10),
33-
np.random.randint(0, 2**60, size=1000, dtype='u8').view('M8[ns]'),
34-
np.random.randint(0, 2**60, size=1000, dtype='u8').view('m8[ns]'),
35-
np.random.randint(0, 2**25, size=1000, dtype='u8').view('M8[m]'),
36-
np.random.randint(0, 2**25, size=1000, dtype='u8').view('m8[m]'),
33+
(-np.random.randint(-2**30, 2**30, size=1000, dtype='i8')).view('M8[ns]'),
34+
(-np.random.randint(-2**30, 2**30, size=1000, dtype='i8')).view('m8[ns]'),
35+
(-np.random.randint(-2**12, 2**13, size=1000, dtype='i8')).view('M8[m]'),
36+
(-np.random.randint(-2**12, 2**13, size=1000, dtype='i8')).view('m8[m]'),
3737
]
3838

3939

numcodecs/tests/test_gzip.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@
3232
np.random.normal(loc=1000, scale=1, size=(100, 10)),
3333
np.random.randint(0, 2, size=1000, dtype=bool).reshape(100, 10, order='F'),
3434
np.random.choice([b'a', b'bb', b'ccc'], size=1000).reshape(10, 10, 10),
35-
np.random.randint(0, 2**60, size=1000, dtype='u8').view('M8[ns]'),
36-
np.random.randint(0, 2**60, size=1000, dtype='u8').view('m8[ns]'),
37-
np.random.randint(0, 2**25, size=1000, dtype='u8').view('M8[m]'),
38-
np.random.randint(0, 2**25, size=1000, dtype='u8').view('m8[m]'),
35+
(-np.random.randint(-2**30, 2**30, size=1000, dtype='i8')).view('M8[ns]'),
36+
(-np.random.randint(-2**30, 2**30, size=1000, dtype='i8')).view('m8[ns]'),
37+
(-np.random.randint(-2**12, 2**13, size=1000, dtype='i8')).view('M8[m]'),
38+
(-np.random.randint(-2**12, 2**13, size=1000, dtype='i8')).view('m8[m]'),
3939
]
4040

4141

numcodecs/tests/test_lz4.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@
3333
np.random.normal(loc=1000, scale=1, size=(100, 10)),
3434
np.random.randint(0, 2, size=1000, dtype=bool).reshape(100, 10, order='F'),
3535
np.random.choice([b'a', b'bb', b'ccc'], size=1000).reshape(10, 10, 10),
36-
np.random.randint(0, 2**60, size=1000, dtype='u8').view('M8[ns]'),
37-
np.random.randint(0, 2**60, size=1000, dtype='u8').view('m8[ns]'),
38-
np.random.randint(0, 2**25, size=1000, dtype='u8').view('M8[m]'),
39-
np.random.randint(0, 2**25, size=1000, dtype='u8').view('m8[m]'),
36+
(-np.random.randint(-2**30, 2**30, size=1000, dtype='i8')).view('M8[ns]'),
37+
(-np.random.randint(-2**30, 2**30, size=1000, dtype='i8')).view('m8[ns]'),
38+
(-np.random.randint(-2**12, 2**13, size=1000, dtype='i8')).view('M8[m]'),
39+
(-np.random.randint(-2**12, 2**13, size=1000, dtype='i8')).view('m8[m]'),
4040
]
4141

4242

numcodecs/tests/test_lzma.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,10 @@
3838
np.random.normal(loc=1000, scale=1, size=(100, 10)),
3939
np.random.randint(0, 2, size=1000, dtype=bool).reshape(100, 10, order='F'),
4040
np.random.choice([b'a', b'bb', b'ccc'], size=1000).reshape(10, 10, 10),
41-
np.random.randint(0, 2**60, size=1000, dtype='u8').view('M8[ns]'),
42-
np.random.randint(0, 2**60, size=1000, dtype='u8').view('m8[ns]'),
43-
np.random.randint(0, 2**25, size=1000, dtype='u8').view('M8[m]'),
44-
np.random.randint(0, 2**25, size=1000, dtype='u8').view('m8[m]'),
41+
(-np.random.randint(-2**30, 2**30, size=1000, dtype='i8')).view('M8[ns]'),
42+
(-np.random.randint(-2**30, 2**30, size=1000, dtype='i8')).view('m8[ns]'),
43+
(-np.random.randint(-2**12, 2**13, size=1000, dtype='i8')).view('M8[m]'),
44+
(-np.random.randint(-2**12, 2**13, size=1000, dtype='i8')).view('m8[m]'),
4545
]
4646

4747

numcodecs/tests/test_zlib.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@
3232
np.random.normal(loc=1000, scale=1, size=(100, 10)),
3333
np.random.randint(0, 2, size=1000, dtype=bool).reshape(100, 10, order='F'),
3434
np.random.choice([b'a', b'bb', b'ccc'], size=1000).reshape(10, 10, 10),
35-
np.random.randint(0, 2**60, size=1000, dtype='u8').view('M8[ns]'),
36-
np.random.randint(0, 2**60, size=1000, dtype='u8').view('m8[ns]'),
37-
np.random.randint(0, 2**25, size=1000, dtype='u8').view('M8[m]'),
38-
np.random.randint(0, 2**25, size=1000, dtype='u8').view('m8[m]'),
35+
(-np.random.randint(-2**30, 2**30, size=1000, dtype='i8')).view('M8[ns]'),
36+
(-np.random.randint(-2**30, 2**30, size=1000, dtype='i8')).view('m8[ns]'),
37+
(-np.random.randint(-2**12, 2**13, size=1000, dtype='i8')).view('M8[m]'),
38+
(-np.random.randint(-2**12, 2**13, size=1000, dtype='i8')).view('m8[m]'),
3939
]
4040

4141

numcodecs/tests/test_zstd.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@
3333
np.random.normal(loc=1000, scale=1, size=(100, 10)),
3434
np.random.randint(0, 2, size=1000, dtype=bool).reshape(100, 10, order='F'),
3535
np.random.choice([b'a', b'bb', b'ccc'], size=1000).reshape(10, 10, 10),
36-
np.random.randint(0, 2**60, size=1000, dtype='u8').view('M8[ns]'),
37-
np.random.randint(0, 2**60, size=1000, dtype='u8').view('m8[ns]'),
38-
np.random.randint(0, 2**25, size=1000, dtype='u8').view('M8[m]'),
39-
np.random.randint(0, 2**25, size=1000, dtype='u8').view('m8[m]'),
36+
(-np.random.randint(-2**30, 2**30, size=1000, dtype='i8')).view('M8[ns]'),
37+
(-np.random.randint(-2**30, 2**30, size=1000, dtype='i8')).view('m8[ns]'),
38+
(-np.random.randint(-2**12, 2**13, size=1000, dtype='i8')).view('M8[m]'),
39+
(-np.random.randint(-2**12, 2**13, size=1000, dtype='i8')).view('m8[m]'),
4040
]
4141

4242

0 commit comments

Comments
 (0)