Skip to content

Commit

Permalink
BUG: CustomBusinessDay apply raises NameError when np.datetime64 is p…
Browse files Browse the repository at this point in the history
…assed
  • Loading branch information
sinhrks committed Jun 3, 2014
1 parent 1754bb5 commit 55b05e7
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions doc/source/v0.14.1.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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`)
4 changes: 1 addition & 3 deletions pandas/tseries/offsets.py
Original file line number Diff line number Diff line change
Expand Up @@ -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())

Expand All @@ -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
Expand All @@ -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

Expand Down
2 changes: 2 additions & 0 deletions pandas/tseries/tests/test_offsets.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 55b05e7

Please sign in to comment.