summaryrefslogtreecommitdiff
path: root/numpy/core
diff options
context:
space:
mode:
Diffstat (limited to 'numpy/core')
-rw-r--r--numpy/core/src/multiarray/datetime_busday.c1
-rw-r--r--numpy/core/tests/test_datetime.py9
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.