Skip to content

Commit a189d5d

Browse files
committed
CLN: failing test on 2.6/windows re GH6866, CustomBusinessMonth
1 parent 07f4966 commit a189d5d

File tree

1 file changed

+16
-29
lines changed

1 file changed

+16
-29
lines changed

pandas/tseries/offsets.py

+16-29
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import sys
21
from datetime import date, datetime, timedelta
32
from pandas.compat import range
43
from pandas import compat
@@ -306,17 +305,8 @@ def _from_name(cls, suffix=None):
306305
return cls()
307306

308307

309-
class BusinessDay(SingleConstructorOffset):
310-
"""
311-
DateOffset subclass representing possibly n business days
312-
"""
313-
_prefix = 'B'
314-
315-
def __init__(self, n=1, **kwds):
316-
self.n = int(n)
317-
self.kwds = kwds
318-
self.offset = kwds.get('offset', timedelta(0))
319-
self.normalize = kwds.get('normalize', False)
308+
class BusinessMixin(object):
309+
""" mixin to business types to provide related functions """
320310

321311
# TODO: Combine this with DateOffset by defining a whitelisted set of
322312
# attributes on each object rather than the existing behavior of iterating
@@ -345,6 +335,18 @@ def __repr__(self):
345335
out += '>'
346336
return out
347337

338+
class BusinessDay(BusinessMixin, SingleConstructorOffset):
339+
"""
340+
DateOffset subclass representing possibly n business days
341+
"""
342+
_prefix = 'B'
343+
344+
def __init__(self, n=1, **kwds):
345+
self.n = int(n)
346+
self.kwds = kwds
347+
self.offset = kwds.get('offset', timedelta(0))
348+
self.normalize = kwds.get('normalize', False)
349+
348350
@property
349351
def freqstr(self):
350352
try:
@@ -706,7 +708,7 @@ def onOffset(cls, dt):
706708

707709

708710

709-
class CustomBusinessMonthEnd(MonthOffset):
711+
class CustomBusinessMonthEnd(BusinessMixin, MonthOffset):
710712
"""
711713
**EXPERIMENTAL** DateOffset of one custom business month
712714
@@ -736,7 +738,6 @@ def __init__(self, n=1, **kwds):
736738
self.offset = kwds.get('offset', timedelta(0))
737739
self.normalize = kwds.get('normalize', False)
738740
self.weekmask = kwds.get('weekmask', 'Mon Tue Wed Thu Fri')
739-
holidays = kwds.get('holidays', [])
740741
self.cbday = CustomBusinessDay(n=self.n,**kwds)
741742
self.m_offset = MonthEnd()
742743

@@ -762,13 +763,7 @@ def apply(self,other):
762763
result = self.cbday.rollback(new)
763764
return as_timestamp(result)
764765

765-
def __repr__(self):
766-
if sys.version_info.major < 3:
767-
return BusinessDay.__repr__.__func__(self)
768-
else:
769-
return BusinessDay.__repr__(self)
770-
771-
class CustomBusinessMonthBegin(MonthOffset):
766+
class CustomBusinessMonthBegin(BusinessMixin, MonthOffset):
772767
"""
773768
**EXPERIMENTAL** DateOffset of one custom business month
774769
@@ -798,7 +793,6 @@ def __init__(self, n=1, **kwds):
798793
self.offset = kwds.get('offset', timedelta(0))
799794
self.normalize = kwds.get('normalize', False)
800795
self.weekmask = kwds.get('weekmask', 'Mon Tue Wed Thu Fri')
801-
holidays = kwds.get('holidays', [])
802796
self.cbday = CustomBusinessDay(n=self.n,**kwds)
803797
self.m_offset = MonthBegin()
804798

@@ -824,13 +818,6 @@ def apply(self,other):
824818
result = self.cbday.rollforward(new)
825819
return as_timestamp(result)
826820

827-
828-
def __repr__(self):
829-
if sys.version_info.major < 3:
830-
return BusinessDay.__repr__.__func__(self)
831-
else:
832-
return BusinessDay.__repr__(self)
833-
834821
class Week(DateOffset):
835822
"""
836823
Weekly offset

0 commit comments

Comments
 (0)