diff options
author | Gerrit Holl <gerrit.holl@utoronto.ca> | 2015-01-15 15:33:18 -0500 |
---|---|---|
committer | Julian Taylor <jtaylor.debian@googlemail.com> | 2015-01-25 17:02:17 +0100 |
commit | 53b19c5bc533f6bc5418e48076f0cd51e3b8c3bd (patch) | |
tree | f3e3dceb5e4ce3283f743d1d8d5511c9f98f2719 | |
parent | f7cdfe6425a3366bae488d20cdf0c87b9bca8096 (diff) | |
download | numpy-53b19c5bc533f6bc5418e48076f0cd51e3b8c3bd.tar.gz |
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.
-rw-r--r-- | numpy/ma/tests/test_core.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/numpy/ma/tests/test_core.py b/numpy/ma/tests/test_core.py index 4ac3465aa..d12df5d81 100644 --- a/numpy/ma/tests/test_core.py +++ b/numpy/ma/tests/test_core.py @@ -1489,6 +1489,21 @@ class TestFillingValues(TestCase): control = np.array((0, 0, 0), dtype="int, float, float").astype(ndtype) assert_equal(_check_fill_value(0, ndtype), control) + def test_fillvalue_datetime_timedelta(self): + # Test default fillvalue for datetime64 and timedelta64 types. + # See issue #4476, this would return '?' which would cause errors + # elsewhere + + for timecode in ("as", "fs", "ps", "ns", "us", "ms", "s", "m", + "h", "D", "W", "M", "Y"): + control = numpy.datetime64("NaT", timecode) + test = default_fill_value(numpy.dtype("<M8[" + timecode + "]")) + assert_equal(test, control) + + control = numpy.timedelta64("NaT", timecode) + test = default_fill_value(numpy.dtype("<m8[" + timecode + "]")) + assert_equal(test, control) + def test_extremum_fill_value(self): # Tests extremum fill values for flexible type. a = array([(1, (2, 3)), (4, (5, 6))], |