Skip to content

Commit 460dfe5

Browse files
committed
edits per reviewer suggestions
1 parent cf6656c commit 460dfe5

File tree

3 files changed

+14
-31
lines changed

3 files changed

+14
-31
lines changed

pandas/tests/tseries/conftest.py

+6
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
import pytest
2+
import pandas.tseries.offsets as offsets
3+
4+
5+
@pytest.fixture(params=[getattr(offsets, o) for o in offsets.__all__])
6+
def offset_types(request):
7+
return request.param
28

39

410
@pytest.fixture(params=[None, 'UTC', 'Asia/Tokyo', 'US/Eastern',

pandas/tests/tseries/test_offsets.py

+8-14
Original file line numberDiff line numberDiff line change
@@ -42,20 +42,6 @@
4242
from pandas.tseries.holiday import USFederalHolidayCalendar
4343

4444

45-
offset_classes = [getattr(offsets, x) for x in dir(offsets)]
46-
offset_classes = [x for x in offset_classes if inspect.isclass(x) and
47-
issubclass(x, DateOffset) and
48-
x not in [offsets.YearOffset, offsets.Tick,
49-
offsets.SingleConstructorOffset,
50-
offsets.SemiMonthOffset,
51-
offsets.QuarterOffset, offsets.MonthOffset]]
52-
53-
54-
@pytest.fixture(params=offset_classes)
55-
def offset_types(request):
56-
return request.param
57-
58-
5945
def test_monthrange():
6046
import calendar
6147
for y in range(2000, 2013):
@@ -4918,6 +4904,14 @@ def test_all_offset_classes(self):
49184904

49194905
# ---------------------------------------------------------------------
49204906

4907+
offset_classes = [getattr(offsets, x) for x in dir(offsets)]
4908+
offset_classes = [x for x in offset_classes if inspect.isclass(x) and
4909+
issubclass(x, DateOffset) and
4910+
x not in [offsets.YearOffset, offsets.Tick,
4911+
offsets.SingleConstructorOffset,
4912+
offsets.SemiMonthOffset,
4913+
offsets.QuarterOffset, offsets.MonthOffset]]
4914+
49214915
month_classes = [x for x in offset_classes if
49224916
issubclass(x, offsets.MonthOffset)]
49234917

pandas/tseries/offsets.py

-17
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,6 @@ def __add__(date):
165165
normalize = False
166166

167167
def __init__(self, n=1, normalize=False, **kwds):
168-
assert n == int(n)
169168
self.n = int(n)
170169
self.normalize = normalize
171170
self.kwds = kwds
@@ -473,7 +472,6 @@ class BusinessDay(BusinessMixin, SingleConstructorOffset):
473472
_adjust_dst = True
474473

475474
def __init__(self, n=1, normalize=False, offset=timedelta(0)):
476-
assert n == int(n)
477475
self.n = int(n)
478476
self.normalize = normalize
479477
self.kwds = {'offset': offset}
@@ -783,7 +781,6 @@ class BusinessHour(BusinessHourMixin, SingleConstructorOffset):
783781

784782
def __init__(self, n=1, normalize=False, start='09:00',
785783
end='17:00', offset=timedelta(0)):
786-
assert n == int(n)
787784
self.n = int(n)
788785
self.normalize = normalize
789786
super(BusinessHour, self).__init__(start=start, end=end, offset=offset)
@@ -821,7 +818,6 @@ class CustomBusinessDay(BusinessDay):
821818

822819
def __init__(self, n=1, normalize=False, weekmask='Mon Tue Wed Thu Fri',
823820
holidays=None, calendar=None, offset=timedelta(0)):
824-
assert n == int(n)
825821
self.n = int(n)
826822
self.normalize = normalize
827823
self._offset = offset
@@ -890,7 +886,6 @@ class CustomBusinessHour(BusinessHourMixin, SingleConstructorOffset):
890886
def __init__(self, n=1, normalize=False, weekmask='Mon Tue Wed Thu Fri',
891887
holidays=None, calendar=None,
892888
start='09:00', end='17:00', offset=timedelta(0)):
893-
assert n == int(n)
894889
self.n = int(n)
895890
self.normalize = normalize
896891
super(CustomBusinessHour, self).__init__(start=start,
@@ -920,7 +915,6 @@ class MonthOffset(SingleConstructorOffset):
920915
_adjust_dst = True
921916

922917
def __init__(self, n=1, normalize=False):
923-
assert n == int(n)
924918
self.n = int(n)
925919
self.normalize = normalize
926920
self._offset = timedelta(1)
@@ -1002,7 +996,6 @@ def __init__(self, n=1, normalize=False, day_of_month=None):
1002996
raise ValueError(msg.format(min=self._min_day_of_month,
1003997
day=self.day_of_month))
1004998

1005-
assert n == int(n)
1006999
self.n = int(n)
10071000
self.normalize = normalize
10081001
self.kwds = {'day_of_month': self.day_of_month}
@@ -1279,7 +1272,6 @@ class CustomBusinessMonthEnd(BusinessMixin, MonthOffset):
12791272

12801273
def __init__(self, n=1, normalize=False, weekmask='Mon Tue Wed Thu Fri',
12811274
holidays=None, calendar=None, offset=timedelta(0)):
1282-
assert n == int(n)
12831275
self.n = int(n)
12841276
self.normalize = normalize
12851277
self._offset = offset
@@ -1351,7 +1343,6 @@ class CustomBusinessMonthBegin(BusinessMixin, MonthOffset):
13511343

13521344
def __init__(self, n=1, normalize=False, weekmask='Mon Tue Wed Thu Fri',
13531345
holidays=None, calendar=None, offset=timedelta(0)):
1354-
assert n == int(n)
13551346
self.n = int(n)
13561347
self.normalize = normalize
13571348
self._offset = offset
@@ -1416,7 +1407,6 @@ class Week(EndMixin, DateOffset):
14161407
_prefix = 'W'
14171408

14181409
def __init__(self, n=1, normalize=False, weekday=None):
1419-
assert n == int(n)
14201410
self.n = int(n)
14211411
self.normalize = normalize
14221412
self.weekday = weekday
@@ -1508,7 +1498,6 @@ class WeekOfMonth(DateOffset):
15081498
_adjust_dst = True
15091499

15101500
def __init__(self, n=1, normalize=False, week=None, weekday=None):
1511-
assert n == int(n)
15121501
self.n = int(n)
15131502
self.normalize = normalize
15141503
self.weekday = weekday
@@ -1605,7 +1594,6 @@ class LastWeekOfMonth(DateOffset):
16051594
_prefix = 'LWOM'
16061595

16071596
def __init__(self, n=1, normalize=False, weekday=None):
1608-
assert n == int(n)
16091597
self.n = int(n)
16101598
self.normalize = normalize
16111599
self.weekday = weekday
@@ -1679,7 +1667,6 @@ class QuarterOffset(DateOffset):
16791667
# point
16801668

16811669
def __init__(self, n=1, normalize=False, startingMonth=None):
1682-
assert n == int(n)
16831670
self.n = int(n)
16841671
self.normalize = normalize
16851672
if startingMonth is None:
@@ -2118,7 +2105,6 @@ class FY5253(DateOffset):
21182105

21192106
def __init__(self, n=1, normalize=False, weekday=0, startingMonth=1,
21202107
variation="nearest"):
2121-
assert n == int(n)
21222108
self.n = int(n)
21232109
self.normalize = normalize
21242110
self.startingMonth = startingMonth
@@ -2369,7 +2355,6 @@ class FY5253Quarter(DateOffset):
23692355

23702356
def __init__(self, n=1, normalize=False, weekday=0, startingMonth=1,
23712357
qtr_with_extra_week=1, variation="nearest"):
2372-
assert n == int(n)
23732358
self.n = int(n)
23742359
self.normalize = normalize
23752360

@@ -2498,7 +2483,6 @@ class Easter(DateOffset):
24982483
_adjust_dst = True
24992484

25002485
def __init__(self, n=1, normalize=False):
2501-
assert n == int(n)
25022486
self.n = int(n)
25032487
self.normalize = normalize
25042488
self._offset = timedelta(1)
@@ -2551,7 +2535,6 @@ class Tick(SingleConstructorOffset):
25512535

25522536
def __init__(self, n=1, normalize=False):
25532537
# TODO: do Tick classes with normalize=True make sense?
2554-
assert n == int(n)
25552538
self.n = int(n)
25562539
self.normalize = normalize
25572540
self._offset = timedelta(1)

0 commit comments

Comments
 (0)