diff options
author | Charles Harris <charlesr.harris@gmail.com> | 2016-01-16 09:47:30 -0700 |
---|---|---|
committer | Charles Harris <charlesr.harris@gmail.com> | 2016-01-16 09:47:30 -0700 |
commit | 4ac1a77f0730f58383ed68615e4d93933cde74f0 (patch) | |
tree | 8a3e206a86cfad08e9abef53ec78757a43925bf3 /numpy/core | |
parent | cc2a6952be7c7a9c5749eac01cfb3289b305308b (diff) | |
parent | 2fbc3f4f86b5b621853d3326a89fd565fd795f9b (diff) | |
download | numpy-4ac1a77f0730f58383ed68615e4d93933cde74f0.tar.gz |
Merge pull request #7028 from sam09/fix-7021
Fix issue #7021
Diffstat (limited to 'numpy/core')
-rw-r--r-- | numpy/core/src/multiarray/datetime_busday.c | 1 | ||||
-rw-r--r-- | numpy/core/tests/test_datetime.py | 9 |
2 files changed, 10 insertions, 0 deletions
diff --git a/numpy/core/src/multiarray/datetime_busday.c b/numpy/core/src/multiarray/datetime_busday.c index 4fade4d20..c04a6c125 100644 --- a/numpy/core/src/multiarray/datetime_busday.c +++ b/numpy/core/src/multiarray/datetime_busday.c @@ -288,6 +288,7 @@ apply_business_day_offset(npy_datetime date, npy_int64 offset, /* If we get a NaT, just return it */ if (date == NPY_DATETIME_NAT) { + *out = NPY_DATETIME_NAT; return 0; } diff --git a/numpy/core/tests/test_datetime.py b/numpy/core/tests/test_datetime.py index 65b1d460a..c79f59c70 100644 --- a/numpy/core/tests/test_datetime.py +++ b/numpy/core/tests/test_datetime.py @@ -1588,6 +1588,15 @@ class TestDateTime(TestCase): assert_equal(np.busday_offset('2007-04-07', -11, weekmask='SatSun'), np.datetime64('2007-02-25')) + # NaT values when roll is not raise + assert_equal(np.busday_offset(np.datetime64('NaT'), 1, roll='nat'), + np.datetime64('NaT')) + assert_equal(np.busday_offset(np.datetime64('NaT'), 1, roll='following'), + np.datetime64('NaT')) + assert_equal(np.busday_offset(np.datetime64('NaT'), 1, roll='preceding'), + np.datetime64('NaT')) + + def test_datetime_busdaycalendar(self): # Check that it removes NaT, duplicates, and weekends # and sorts the result. |