8000 TST: Add testcase for the fix to bug #4476. · numpy/numpy@00ee332 · GitHub
[go: up one dir, main page]

Skip to content

Commit 00ee332

Browse files
author
Gerrit Holl
committed
TST: Add testcase for the fix to bug #4476.
Add a testcase `test_fillvalue_datetime_timedelta` to class `TestFillingValues` for the fix to bug #4476. See commit 216fd17 and pull request #5455.
1 parent 4bfcf48 commit 00ee332

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

numpy/ma/tests/test_core.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1489,6 +1489,21 @@ def test_fillvalue_exotic_dtype(self):
14891489
control = np.array((0, 0, 0), dtype="int, float, float").astype(ndtype)
14901490
assert_equal(_check_fill_value(0, ndtype), control)
14911491

1492+
def test_fillvalue_datetime_timedelta(self):
1493+
# Test default fillvalue for datetime64 and timedelta64 types.
1494+
# See issue #4476, this would return '?' which would cause errors
1495+
# elsewhere
1496+
1497+
for timecode in ("as", "fs", "ps", "ns", "us", "ms", "s", "m",
1498+
"h", "D", "W", "M", "Y"):
1499+
control = numpy.datetime64("NaT", timecode)
1500+
test = default_fill_value(numpy.dtype("<M8[" + timecode + "]"))
1501+
assert_equal(test, control)
1502+
1503+
control = numpy.timedelta64("NaT", timecode)
1504+
test = default_fill_value(numpy.dtype("<m8[" + timecode + "]"))
1505+
assert_equal(test, control)
1506+
14921507
def test_extremum_fill_value(self):
14931508
# Tests extremum fill values for flexible type.
14941509
a = array([(1, (2, 3)), (4, (5, 6))],

0 commit comments

Comments
 (0)
0