Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

BUG: CustomBusinessDay apply raises NameError when np.datetime64 is pass... #7196

Merged
merged 1 commit into from Jun 4, 2014
Jump to file or symbol
Failed to load files and symbols.
+4 −3
Split
View
@@ -86,3 +86,4 @@ Bug Fixes
wouldn't test ``True`` when it encountered an ``inf``/``-inf``
(:issue:`7315`).
- Bug in inferred_freq results in None for eastern hemisphere timezones (:issue:`7310`)
+- Bug in ``CustomBusinessDay.apply`` raiases ``NameError`` when ``np.datetime64`` object is passed (:issue:`7196`)
@@ -528,7 +528,6 @@ def apply(self, other):
# Distinguish input cases to enhance performance
if isinstance(other, datetime):
- dtype = type(other)
date_in = other
np_dt = np.datetime64(date_in.date())
@@ -547,7 +546,6 @@ def apply(self, other):
return as_timestamp(result)
elif isinstance(other, np.datetime64):
- dtype = other.dtype
date_in = other
np_day = date_in.astype('datetime64[D]')
np_time = date_in - np_day
@@ -556,7 +554,7 @@ def apply(self, other):
busdaycal=self.busdaycalendar)
if not self.normalize:
- result = np_day_incr + np_time
+ result = np_incr_dt + np_time
else:
result = np_incr_dt
@@ -382,6 +382,7 @@ class TestCustomBusinessDay(Base):
def setUp(self):
self.d = datetime(2008, 1, 1)
+ self.nd = np.datetime64('2008-01-01 00:00:00Z')
_skip_if_no_cday()
self.offset = CDay()
@@ -417,6 +418,7 @@ def test_hash(self):
def testCall(self):
self.assertEqual(self.offset2(self.d), datetime(2008, 1, 3))
+ self.assertEqual(self.offset2(self.nd), datetime(2008, 1, 3))
def testRAdd(self):
self.assertEqual(self.d + self.offset2, self.offset2 + self.d)