Skip to content
New issue

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

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lock down kwargs in offsets signatures #17458

Merged
merged 22 commits into from
Oct 6, 2017
Merged
Changes from 1 commit
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
5e276c9
Lock down kwargs in offsets signatures
jbrockmendel Sep 7, 2017
0183e50
whatsnew note
jbrockmendel Sep 7, 2017
e33626e
Merge branch 'master' of https://github.com/pandas-dev/pandas into of…
jbrockmendel Sep 8, 2017
1377df1
Merge branch 'master' of https://github.com/pandas-dev/pandas into of…
jbrockmendel Sep 24, 2017
ed78a4a
restrict YearOffset to month kwarg
jbrockmendel Sep 24, 2017
36290d2
Restrict SemiMonthOffset kwargs to day_of_month
jbrockmendel Sep 24, 2017
4443d6c
Lock down kwargs in FY5253 and FY5253Quarter
jbrockmendel Sep 24, 2017
8cb6b66
lock down kwargs in BusinessDay, CustomBusinessMonthEnd
jbrockmendel Sep 24, 2017
fe7bb56
Lockdown kwargs in remaining DateOffset subclasses
jbrockmendel Sep 24, 2017
3daab66
Briefer WhatsNew, add missing kwds attrs
jbrockmendel Sep 24, 2017
aefb68c
whitespace fixups
jbrockmendel Sep 24, 2017
1e06d99
Move doc section to other api changes bullet point
jbrockmendel Sep 26, 2017
7be31da
Merge branch 'master' into offset_sigs
jbrockmendel Sep 26, 2017
cd1f224
Add pickle tests for 0.19.2 and 0.20.3
jbrockmendel Sep 29, 2017
97c896e
Merge branch 'offset_sigs' of https://github.com/jbrockmendel/pandas …
jbrockmendel Sep 29, 2017
e93de50
Merge branch 'master' of https://github.com/pandas-dev/pandas into of…
jbrockmendel Sep 29, 2017
7426265
Merge branch 'master' of https://github.com/pandas-dev/pandas into of…
jbrockmendel Oct 2, 2017
aee75de
New version of test_pickle_v0_20_3
jbrockmendel Oct 2, 2017
cc5a71a
flake8 whitespace fixup
jbrockmendel Oct 3, 2017
521a8d0
Merge branch 'master' of https://github.com/pandas-dev/pandas into of…
jbrockmendel Oct 3, 2017
217a558
remove test per reviewer instruction
jbrockmendel Oct 4, 2017
086b485
Add offsets with kwds to generate_legacy_storage_files
jbrockmendel Oct 6, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Lockdown kwargs in remaining DateOffset subclasses
  • Loading branch information
jbrockmendel committed Sep 24, 2017
commit fe7bb56c29c1885aaf826bf346aa49a5b819c1eb
31 changes: 16 additions & 15 deletions pandas/tseries/offsets.py
Original file line number Diff line number Diff line change
Expand Up @@ -693,14 +693,13 @@ def onOffset(self, dt):

class BusinessHourMixin(BusinessMixin):

def __init__(self, **kwds):
def __init__(self, start='09:00', end='17:00', offset=timedelta(0)):
# must be validated here to equality check
kwds['start'] = self._validate_time(kwds.get('start', '09:00'))
kwds['end'] = self._validate_time(kwds.get('end', '17:00'))
kwds = {'offset': offset}
self.start = kwds['start'] = self._validate_time(start)
self.end = kwds['end'] = self._validate_time(end)
self.kwds = kwds
self._offset = kwds.get('offset', timedelta(0))
self.start = kwds.get('start', '09:00')
self.end = kwds.get('end', '17:00')
self._offset = offset

def _validate_time(self, t_input):
from datetime import time as dt_time
Expand Down Expand Up @@ -923,10 +922,11 @@ class BusinessHour(BusinessHourMixin, SingleConstructorOffset):
_prefix = 'BH'
_anchor = 0

def __init__(self, n=1, normalize=False, **kwds):
def __init__(self, n=1, normalize=False, start='09:00',
end='17:00', offset=timedelta(0)):
self.n = int(n)
self.normalize = normalize
super(BusinessHour, self).__init__(**kwds)
super(BusinessHour, self).__init__(start=start, end=end, offset=offset)

@cache_readonly
def next_bday(self):
Expand Down Expand Up @@ -960,11 +960,10 @@ class CustomBusinessDay(BusinessDay):
_prefix = 'C'

def __init__(self, n=1, normalize=False, weekmask='Mon Tue Wed Thu Fri',
holidays=None, calendar=None, **kwds):
holidays=None, calendar=None, offset=timedelta(0)):
self.n = int(n)
self.normalize = normalize
self.kwds = kwds
self._offset = kwds.get('offset', timedelta(0))
self._offset = offset

calendar, holidays = _get_calendar(weekmask=weekmask,
holidays=holidays,
Expand All @@ -976,6 +975,7 @@ def __init__(self, n=1, normalize=False, weekmask='Mon Tue Wed Thu Fri',
self.kwds['weekmask'] = self.weekmask = weekmask
self.kwds['holidays'] = self.holidays = holidays
self.kwds['calendar'] = self.calendar = calendar
self.kwds['offset'] = offset

@apply_wraps
def apply(self, other):
Expand Down Expand Up @@ -1026,10 +1026,12 @@ class CustomBusinessHour(BusinessHourMixin, SingleConstructorOffset):
_anchor = 0

def __init__(self, n=1, normalize=False, weekmask='Mon Tue Wed Thu Fri',
holidays=None, calendar=None, **kwds):
holidays=None, calendar=None,
start='09:00', end='17:00', offset=timedelta(0)):
self.n = int(n)
self.normalize = normalize
super(CustomBusinessHour, self).__init__(**kwds)
super(CustomBusinessHour, self).__init__(start=start,
end=end, offset=offset)

calendar, holidays = _get_calendar(weekmask=weekmask,
holidays=holidays,
Expand Down Expand Up @@ -2025,8 +2027,7 @@ def __init__(self, n=1, normalize=False, month=None):
if self.month < 1 or self.month > 12:
raise ValueError('Month must go from 1 to 12')

kwds = {'month': month}
DateOffset.__init__(self, n=n, normalize=normalize, **kwds)
DateOffset.__init__(self, n=n, normalize=normalize, month=month)

@classmethod
def _from_name(cls, suffix=None):
Expand Down