Skip to content

Commit a72d951

Browse files
committed
Merge pull request #8085 from mortada/pep8_cleanup
CLN: PEP8 cleanup of holiday.py
2 parents 995f91c + dca303e commit a72d951

File tree

1 file changed

+26
-27
lines changed

1 file changed

+26
-27
lines changed

pandas/tseries/holiday.py

+26-27
Original file line numberDiff line numberDiff line change
@@ -129,10 +129,10 @@ class from pandas.tseries.offsets
129129
computes offset from date
130130
observance: function
131131
computes when holiday is given a pandas Timestamp
132-
days_of_week:
132+
days_of_week:
133133
provide a tuple of days e.g (0,1,2,3,) for Monday Through Thursday
134134
Monday=0,..,Sunday=6
135-
135+
136136
Examples
137137
--------
138138
>>> from pandas.tseries.holiday import Holiday, nearest_workday
@@ -148,13 +148,13 @@ class from pandas.tseries.offsets
148148
>>> July3rd = Holiday('July 3rd', month=7, day=3,
149149
days_of_week=(0, 1, 2, 3))
150150
"""
151-
self.name = name
152-
self.year = year
153-
self.month = month
154-
self.day = day
155-
self.offset = offset
151+
self.name = name
152+
self.year = year
153+
self.month = month
154+
self.day = day
155+
self.offset = offset
156156
self.start_date = start_date
157-
self.end_date = end_date
157+
self.end_date = end_date
158158
self.observance = observance
159159
assert (days_of_week is None or type(days_of_week) == tuple)
160160
self.days_of_week = days_of_week
@@ -200,14 +200,14 @@ def dates(self, start_date, end_date, return_name=False):
200200
end_date = self.end_date
201201

202202
start_date = Timestamp(start_date)
203-
end_date = Timestamp(end_date)
203+
end_date = Timestamp(end_date)
204204

205205
year_offset = DateOffset(years=1)
206206
base_date = Timestamp(datetime(start_date.year, self.month, self.day))
207207
dates = DatetimeIndex(start=base_date, end=end_date, freq=year_offset)
208208
holiday_dates = self._apply_rule(dates)
209209
if self.days_of_week is not None:
210-
holiday_dates = list(filter(lambda x: x is not None and
210+
holiday_dates = list(filter(lambda x: x is not None and
211211
x.dayofweek in self.days_of_week,
212212
holiday_dates))
213213
else:
@@ -235,9 +235,9 @@ def _apply_rule(self, dates):
235235

236236
if self.offset is not None:
237237
if not isinstance(self.offset, list):
238-
offsets = [self.offset]
238+
offsets = [self.offset]
239239
else:
240-
offsets = self.offset
240+
offsets = self.offset
241241
for offset in offsets:
242242
dates = list(map(lambda d: d + offset, dates))
243243
return dates
@@ -275,7 +275,7 @@ class AbstractHolidayCalendar(object):
275275
__metaclass__ = HolidayCalendarMetaClass
276276
rules = []
277277
start_date = Timestamp(datetime(1970, 1, 1))
278-
end_date = Timestamp(datetime(2030, 12, 31))
278+
end_date = Timestamp(datetime(2030, 12, 31))
279279
_holiday_cache = None
280280

281281
def __init__(self, name=None, rules=None):
@@ -315,7 +315,7 @@ def holidays(self, start=None, end=None, return_name=False):
315315
DatetimeIndex of holidays
316316
"""
317317
if self.rules is None:
318-
raise Exception('Holiday Calendar %s does not have any '\
318+
raise Exception('Holiday Calendar %s does not have any '
319319
'rules specified' % self.name)
320320

321321
if start is None:
@@ -325,7 +325,7 @@ def holidays(self, start=None, end=None, return_name=False):
325325
end = AbstractHolidayCalendar.end_date
326326

327327
start = Timestamp(start)
328-
end = Timestamp(end)
328+
end = Timestamp(end)
329329

330330
holidays = None
331331
# If we don't have a cache or the dates are outside the prior cache, we get them again
@@ -359,7 +359,7 @@ def _cache(self, values):
359359
@staticmethod
360360
def merge_class(base, other):
361361
"""
362-
Merge holiday calendars together. The base calendar
362+
Merge holiday calendars together. The base calendar
363363
will take precedence to other. The merge will be done
364364
based on each holiday's name.
365365
@@ -384,7 +384,7 @@ def merge_class(base, other):
384384

385385
if not isinstance(base, list):
386386
base = [base]
387-
base_holidays = dict([ (holiday.name,holiday) for holiday in base ])
387+
base_holidays = dict([(holiday.name, holiday) for holiday in base])
388388

389389
other_holidays.update(base_holidays)
390390
return list(other_holidays.values())
@@ -401,30 +401,29 @@ def merge(self, other, inplace=False):
401401
inplace : bool (default=False)
402402
If True set rule_table to holidays, else return array of Holidays
403403
"""
404-
holidays = self.merge_class(self, other)
404+
holidays = self.merge_class(self, other)
405405
if inplace:
406406
self.rules = holidays
407407
else:
408408
return holidays
409409

410-
USMemorialDay = Holiday('MemorialDay', month=5, day=24,
411-
offset=DateOffset(weekday=MO(1)))
412-
USLaborDay = Holiday('Labor Day', month=9, day=1,
413-
offset=DateOffset(weekday=MO(1)))
414-
USColumbusDay = Holiday('Columbus Day', month=10, day=1,
415-
offset=DateOffset(weekday=MO(2)))
410+
USMemorialDay = Holiday('MemorialDay', month=5, day=24,
411+
offset=DateOffset(weekday=MO(1)))
412+
USLaborDay = Holiday('Labor Day', month=9, day=1,
413+
offset=DateOffset(weekday=MO(1)))
414+
USColumbusDay = Holiday('Columbus Day', month=10, day=1,
415+
offset=DateOffset(weekday=MO(2)))
416416
USThanksgivingDay = Holiday('Thanksgiving', month=11, day=1,
417417
offset=DateOffset(weekday=TH(4)))
418418
USMartinLutherKingJr = Holiday('Dr. Martin Luther King Jr.', month=1, day=1,
419419
offset=DateOffset(weekday=MO(3)))
420-
USPresidentsDay = Holiday('President''s Day', month=2, day=1,
421-
offset=DateOffset(weekday=MO(3)))
420+
USPresidentsDay = Holiday('President''s Day', month=2, day=1,
421+
offset=DateOffset(weekday=MO(3)))
422422
GoodFriday = Holiday("Good Friday", month=1, day=1, offset=[Easter(), Day(-2)])
423423

424424
EasterMonday = Holiday("Easter Monday", month=1, day=1, offset=[Easter(), Day(1)])
425425

426426

427-
428427
class USFederalHolidayCalendar(AbstractHolidayCalendar):
429428
"""
430429
US Federal Government Holiday Calendar based on rules specified

0 commit comments

Comments
 (0)