Python pandas.tseries.offsets.FY5253 Examples
The following are 30
code examples of pandas.tseries.offsets.FY5253().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
pandas.tseries.offsets
, or try the search function
.
Example #1
Source File: test_fiscal.py From twitter-stock-recommendation with MIT License | 6 votes |
def test_bunched_yearends(): # GH#14774 cases with two fiscal year-ends in the same calendar-year fy = FY5253(n=1, weekday=5, startingMonth=12, variation='nearest') dt = Timestamp('2004-01-01') assert fy.rollback(dt) == Timestamp('2002-12-28') assert (-fy).apply(dt) == Timestamp('2002-12-28') assert dt - fy == Timestamp('2002-12-28') assert fy.rollforward(dt) == Timestamp('2004-01-03') assert fy.apply(dt) == Timestamp('2004-01-03') assert fy + dt == Timestamp('2004-01-03') assert dt + fy == Timestamp('2004-01-03') # Same thing, but starting from a Timestamp in the previous year. dt = Timestamp('2003-12-31') assert fy.rollback(dt) == Timestamp('2002-12-28') assert (-fy).apply(dt) == Timestamp('2002-12-28') assert dt - fy == Timestamp('2002-12-28')
Example #2
Source File: test_fiscal.py From recruit with Apache License 2.0 | 6 votes |
def test_bunched_yearends(): # GH#14774 cases with two fiscal year-ends in the same calendar-year fy = FY5253(n=1, weekday=5, startingMonth=12, variation='nearest') dt = Timestamp('2004-01-01') assert fy.rollback(dt) == Timestamp('2002-12-28') assert (-fy).apply(dt) == Timestamp('2002-12-28') assert dt - fy == Timestamp('2002-12-28') assert fy.rollforward(dt) == Timestamp('2004-01-03') assert fy.apply(dt) == Timestamp('2004-01-03') assert fy + dt == Timestamp('2004-01-03') assert dt + fy == Timestamp('2004-01-03') # Same thing, but starting from a Timestamp in the previous year. dt = Timestamp('2003-12-31') assert fy.rollback(dt) == Timestamp('2002-12-28') assert (-fy).apply(dt) == Timestamp('2002-12-28') assert dt - fy == Timestamp('2002-12-28')
Example #3
Source File: test_fiscal.py From coffeegrindsize with MIT License | 6 votes |
def test_bunched_yearends(): # GH#14774 cases with two fiscal year-ends in the same calendar-year fy = FY5253(n=1, weekday=5, startingMonth=12, variation='nearest') dt = Timestamp('2004-01-01') assert fy.rollback(dt) == Timestamp('2002-12-28') assert (-fy).apply(dt) == Timestamp('2002-12-28') assert dt - fy == Timestamp('2002-12-28') assert fy.rollforward(dt) == Timestamp('2004-01-03') assert fy.apply(dt) == Timestamp('2004-01-03') assert fy + dt == Timestamp('2004-01-03') assert dt + fy == Timestamp('2004-01-03') # Same thing, but starting from a Timestamp in the previous year. dt = Timestamp('2003-12-31') assert fy.rollback(dt) == Timestamp('2002-12-28') assert (-fy).apply(dt) == Timestamp('2002-12-28') assert dt - fy == Timestamp('2002-12-28')
Example #4
Source File: test_fiscal.py From vnpy_crypto with MIT License | 6 votes |
def test_bunched_yearends(): # GH#14774 cases with two fiscal year-ends in the same calendar-year fy = FY5253(n=1, weekday=5, startingMonth=12, variation='nearest') dt = Timestamp('2004-01-01') assert fy.rollback(dt) == Timestamp('2002-12-28') assert (-fy).apply(dt) == Timestamp('2002-12-28') assert dt - fy == Timestamp('2002-12-28') assert fy.rollforward(dt) == Timestamp('2004-01-03') assert fy.apply(dt) == Timestamp('2004-01-03') assert fy + dt == Timestamp('2004-01-03') assert dt + fy == Timestamp('2004-01-03') # Same thing, but starting from a Timestamp in the previous year. dt = Timestamp('2003-12-31') assert fy.rollback(dt) == Timestamp('2002-12-28') assert (-fy).apply(dt) == Timestamp('2002-12-28') assert dt - fy == Timestamp('2002-12-28')
Example #5
Source File: test_fiscal.py From predictive-maintenance-using-machine-learning with Apache License 2.0 | 6 votes |
def test_bunched_yearends(): # GH#14774 cases with two fiscal year-ends in the same calendar-year fy = FY5253(n=1, weekday=5, startingMonth=12, variation='nearest') dt = Timestamp('2004-01-01') assert fy.rollback(dt) == Timestamp('2002-12-28') assert (-fy).apply(dt) == Timestamp('2002-12-28') assert dt - fy == Timestamp('2002-12-28') assert fy.rollforward(dt) == Timestamp('2004-01-03') assert fy.apply(dt) == Timestamp('2004-01-03') assert fy + dt == Timestamp('2004-01-03') assert dt + fy == Timestamp('2004-01-03') # Same thing, but starting from a Timestamp in the previous year. dt = Timestamp('2003-12-31') assert fy.rollback(dt) == Timestamp('2002-12-28') assert (-fy).apply(dt) == Timestamp('2002-12-28') assert dt - fy == Timestamp('2002-12-28')
Example #6
Source File: test_fiscal.py From predictive-maintenance-using-machine-learning with Apache License 2.0 | 5 votes |
def test_get_year_end(self): assert (makeFY5253NearestEndMonth( startingMonth=8, weekday=WeekDay.SAT).get_year_end( datetime(2013, 1, 1)) == datetime(2013, 8, 31)) assert (makeFY5253NearestEndMonth( startingMonth=8, weekday=WeekDay.SUN).get_year_end( datetime(2013, 1, 1)) == datetime(2013, 9, 1)) assert (makeFY5253NearestEndMonth( startingMonth=8, weekday=WeekDay.FRI).get_year_end( datetime(2013, 1, 1)) == datetime(2013, 8, 30)) offset_n = FY5253(weekday=WeekDay.TUE, startingMonth=12, variation="nearest") assert (offset_n.get_year_end(datetime(2012, 1, 1)) == datetime(2013, 1, 1)) assert (offset_n.get_year_end(datetime(2012, 1, 10)) == datetime(2013, 1, 1)) assert (offset_n.get_year_end(datetime(2013, 1, 1)) == datetime(2013, 12, 31)) assert (offset_n.get_year_end(datetime(2013, 1, 2)) == datetime(2013, 12, 31)) assert (offset_n.get_year_end(datetime(2013, 1, 3)) == datetime(2013, 12, 31)) assert (offset_n.get_year_end(datetime(2013, 1, 10)) == datetime(2013, 12, 31)) JNJ = FY5253(n=1, startingMonth=12, weekday=6, variation="nearest") assert (JNJ.get_year_end(datetime(2006, 1, 1)) == datetime(2006, 12, 31))
Example #7
Source File: test_fiscal.py From twitter-stock-recommendation with MIT License | 5 votes |
def test_fy5253_nearest_onoffset(): # GH#18877 dates on the year-end but not normalized to midnight offset = FY5253(n=3, startingMonth=7, variation="nearest", weekday=2) ts = Timestamp('2032-07-28 00:12:59.035729419+0000', tz='Africa/Dakar') fast = offset.onOffset(ts) slow = (ts + offset) - offset == ts assert fast == slow
Example #8
Source File: test_fiscal.py From twitter-stock-recommendation with MIT License | 5 votes |
def test_get_year_end(self): assert (makeFY5253NearestEndMonth( startingMonth=8, weekday=WeekDay.SAT).get_year_end( datetime(2013, 1, 1)) == datetime(2013, 8, 31)) assert (makeFY5253NearestEndMonth( startingMonth=8, weekday=WeekDay.SUN).get_year_end( datetime(2013, 1, 1)) == datetime(2013, 9, 1)) assert (makeFY5253NearestEndMonth( startingMonth=8, weekday=WeekDay.FRI).get_year_end( datetime(2013, 1, 1)) == datetime(2013, 8, 30)) offset_n = FY5253(weekday=WeekDay.TUE, startingMonth=12, variation="nearest") assert (offset_n.get_year_end(datetime(2012, 1, 1)) == datetime(2013, 1, 1)) assert (offset_n.get_year_end(datetime(2012, 1, 10)) == datetime(2013, 1, 1)) assert (offset_n.get_year_end(datetime(2013, 1, 1)) == datetime(2013, 12, 31)) assert (offset_n.get_year_end(datetime(2013, 1, 2)) == datetime(2013, 12, 31)) assert (offset_n.get_year_end(datetime(2013, 1, 3)) == datetime(2013, 12, 31)) assert (offset_n.get_year_end(datetime(2013, 1, 10)) == datetime(2013, 12, 31)) JNJ = FY5253(n=1, startingMonth=12, weekday=6, variation="nearest") assert (JNJ.get_year_end(datetime(2006, 1, 1)) == datetime(2006, 12, 31))
Example #9
Source File: test_fiscal.py From twitter-stock-recommendation with MIT License | 5 votes |
def makeFY5253LastOfMonth(*args, **kwds): return FY5253(*args, variation="last", **kwds)
Example #10
Source File: test_fiscal.py From twitter-stock-recommendation with MIT License | 5 votes |
def makeFY5253NearestEndMonth(*args, **kwds): return FY5253(*args, variation="nearest", **kwds)
Example #11
Source File: test_fiscal.py From coffeegrindsize with MIT License | 5 votes |
def test_fy5253_nearest_onoffset(): # GH#18877 dates on the year-end but not normalized to midnight offset = FY5253(n=3, startingMonth=7, variation="nearest", weekday=2) ts = Timestamp('2032-07-28 00:12:59.035729419+0000', tz='Africa/Dakar') fast = offset.onOffset(ts) slow = (ts + offset) - offset == ts assert fast == slow
Example #12
Source File: test_fiscal.py From coffeegrindsize with MIT License | 5 votes |
def test_get_year_end(self): assert (makeFY5253NearestEndMonth( startingMonth=8, weekday=WeekDay.SAT).get_year_end( datetime(2013, 1, 1)) == datetime(2013, 8, 31)) assert (makeFY5253NearestEndMonth( startingMonth=8, weekday=WeekDay.SUN).get_year_end( datetime(2013, 1, 1)) == datetime(2013, 9, 1)) assert (makeFY5253NearestEndMonth( startingMonth=8, weekday=WeekDay.FRI).get_year_end( datetime(2013, 1, 1)) == datetime(2013, 8, 30)) offset_n = FY5253(weekday=WeekDay.TUE, startingMonth=12, variation="nearest") assert (offset_n.get_year_end(datetime(2012, 1, 1)) == datetime(2013, 1, 1)) assert (offset_n.get_year_end(datetime(2012, 1, 10)) == datetime(2013, 1, 1)) assert (offset_n.get_year_end(datetime(2013, 1, 1)) == datetime(2013, 12, 31)) assert (offset_n.get_year_end(datetime(2013, 1, 2)) == datetime(2013, 12, 31)) assert (offset_n.get_year_end(datetime(2013, 1, 3)) == datetime(2013, 12, 31)) assert (offset_n.get_year_end(datetime(2013, 1, 10)) == datetime(2013, 12, 31)) JNJ = FY5253(n=1, startingMonth=12, weekday=6, variation="nearest") assert (JNJ.get_year_end(datetime(2006, 1, 1)) == datetime(2006, 12, 31))
Example #13
Source File: test_fiscal.py From coffeegrindsize with MIT License | 5 votes |
def makeFY5253LastOfMonth(*args, **kwds): return FY5253(*args, variation="last", **kwds)
Example #14
Source File: test_fiscal.py From coffeegrindsize with MIT License | 5 votes |
def makeFY5253NearestEndMonth(*args, **kwds): return FY5253(*args, variation="nearest", **kwds)
Example #15
Source File: test_fiscal.py From predictive-maintenance-using-machine-learning with Apache License 2.0 | 5 votes |
def test_fy5253_nearest_onoffset(): # GH#18877 dates on the year-end but not normalized to midnight offset = FY5253(n=3, startingMonth=7, variation="nearest", weekday=2) ts = Timestamp('2032-07-28 00:12:59.035729419+0000', tz='Africa/Dakar') fast = offset.onOffset(ts) slow = (ts + offset) - offset == ts assert fast == slow
Example #16
Source File: test_fiscal.py From recruit with Apache License 2.0 | 5 votes |
def makeFY5253NearestEndMonth(*args, **kwds): return FY5253(*args, variation="nearest", **kwds)
Example #17
Source File: test_fiscal.py From predictive-maintenance-using-machine-learning with Apache License 2.0 | 5 votes |
def makeFY5253LastOfMonth(*args, **kwds): return FY5253(*args, variation="last", **kwds)
Example #18
Source File: test_fiscal.py From predictive-maintenance-using-machine-learning with Apache License 2.0 | 5 votes |
def makeFY5253NearestEndMonth(*args, **kwds): return FY5253(*args, variation="nearest", **kwds)
Example #19
Source File: test_timeseries.py From Computable with MIT License | 5 votes |
def test_date_range_fy5252(self): dr = date_range(start="2013-01-01", periods=2, freq=offsets.FY5253(startingMonth=1, weekday=3, variation="nearest")) self.assertEqual(dr[0], Timestamp('2013-01-31')) self.assertEqual(dr[1], Timestamp('2014-01-30'))
Example #20
Source File: test_fiscal.py From vnpy_crypto with MIT License | 5 votes |
def test_fy5253_nearest_onoffset(): # GH#18877 dates on the year-end but not normalized to midnight offset = FY5253(n=3, startingMonth=7, variation="nearest", weekday=2) ts = Timestamp('2032-07-28 00:12:59.035729419+0000', tz='Africa/Dakar') fast = offset.onOffset(ts) slow = (ts + offset) - offset == ts assert fast == slow
Example #21
Source File: test_fiscal.py From vnpy_crypto with MIT License | 5 votes |
def test_get_year_end(self): assert (makeFY5253NearestEndMonth( startingMonth=8, weekday=WeekDay.SAT).get_year_end( datetime(2013, 1, 1)) == datetime(2013, 8, 31)) assert (makeFY5253NearestEndMonth( startingMonth=8, weekday=WeekDay.SUN).get_year_end( datetime(2013, 1, 1)) == datetime(2013, 9, 1)) assert (makeFY5253NearestEndMonth( startingMonth=8, weekday=WeekDay.FRI).get_year_end( datetime(2013, 1, 1)) == datetime(2013, 8, 30)) offset_n = FY5253(weekday=WeekDay.TUE, startingMonth=12, variation="nearest") assert (offset_n.get_year_end(datetime(2012, 1, 1)) == datetime(2013, 1, 1)) assert (offset_n.get_year_end(datetime(2012, 1, 10)) == datetime(2013, 1, 1)) assert (offset_n.get_year_end(datetime(2013, 1, 1)) == datetime(2013, 12, 31)) assert (offset_n.get_year_end(datetime(2013, 1, 2)) == datetime(2013, 12, 31)) assert (offset_n.get_year_end(datetime(2013, 1, 3)) == datetime(2013, 12, 31)) assert (offset_n.get_year_end(datetime(2013, 1, 10)) == datetime(2013, 12, 31)) JNJ = FY5253(n=1, startingMonth=12, weekday=6, variation="nearest") assert (JNJ.get_year_end(datetime(2006, 1, 1)) == datetime(2006, 12, 31))
Example #22
Source File: test_fiscal.py From vnpy_crypto with MIT License | 5 votes |
def makeFY5253LastOfMonth(*args, **kwds): return FY5253(*args, variation="last", **kwds)
Example #23
Source File: test_fiscal.py From vnpy_crypto with MIT License | 5 votes |
def makeFY5253NearestEndMonth(*args, **kwds): return FY5253(*args, variation="nearest", **kwds)
Example #24
Source File: test_fiscal.py From recruit with Apache License 2.0 | 5 votes |
def test_fy5253_nearest_onoffset(): # GH#18877 dates on the year-end but not normalized to midnight offset = FY5253(n=3, startingMonth=7, variation="nearest", weekday=2) ts = Timestamp('2032-07-28 00:12:59.035729419+0000', tz='Africa/Dakar') fast = offset.onOffset(ts) slow = (ts + offset) - offset == ts assert fast == slow
Example #25
Source File: test_fiscal.py From recruit with Apache License 2.0 | 5 votes |
def test_get_year_end(self): assert (makeFY5253NearestEndMonth( startingMonth=8, weekday=WeekDay.SAT).get_year_end( datetime(2013, 1, 1)) == datetime(2013, 8, 31)) assert (makeFY5253NearestEndMonth( startingMonth=8, weekday=WeekDay.SUN).get_year_end( datetime(2013, 1, 1)) == datetime(2013, 9, 1)) assert (makeFY5253NearestEndMonth( startingMonth=8, weekday=WeekDay.FRI).get_year_end( datetime(2013, 1, 1)) == datetime(2013, 8, 30)) offset_n = FY5253(weekday=WeekDay.TUE, startingMonth=12, variation="nearest") assert (offset_n.get_year_end(datetime(2012, 1, 1)) == datetime(2013, 1, 1)) assert (offset_n.get_year_end(datetime(2012, 1, 10)) == datetime(2013, 1, 1)) assert (offset_n.get_year_end(datetime(2013, 1, 1)) == datetime(2013, 12, 31)) assert (offset_n.get_year_end(datetime(2013, 1, 2)) == datetime(2013, 12, 31)) assert (offset_n.get_year_end(datetime(2013, 1, 3)) == datetime(2013, 12, 31)) assert (offset_n.get_year_end(datetime(2013, 1, 10)) == datetime(2013, 12, 31)) JNJ = FY5253(n=1, startingMonth=12, weekday=6, variation="nearest") assert (JNJ.get_year_end(datetime(2006, 1, 1)) == datetime(2006, 12, 31))
Example #26
Source File: test_fiscal.py From recruit with Apache License 2.0 | 5 votes |
def makeFY5253LastOfMonth(*args, **kwds): return FY5253(*args, variation="last", **kwds)
Example #27
Source File: test_fiscal.py From predictive-maintenance-using-machine-learning with Apache License 2.0 | 4 votes |
def test_apply(self): date_seq_nem_8_sat = [datetime(2006, 9, 2), datetime(2007, 9, 1), datetime(2008, 8, 30), datetime(2009, 8, 29), datetime(2010, 8, 28), datetime(2011, 9, 3)] JNJ = [datetime(2005, 1, 2), datetime(2006, 1, 1), datetime(2006, 12, 31), datetime(2007, 12, 30), datetime(2008, 12, 28), datetime(2010, 1, 3), datetime(2011, 1, 2), datetime(2012, 1, 1), datetime(2012, 12, 30)] DEC_SAT = FY5253(n=-1, startingMonth=12, weekday=5, variation="nearest") tests = [ (makeFY5253NearestEndMonth(startingMonth=8, weekday=WeekDay.SAT), date_seq_nem_8_sat), (makeFY5253NearestEndMonth(n=1, startingMonth=8, weekday=WeekDay.SAT), date_seq_nem_8_sat), (makeFY5253NearestEndMonth(startingMonth=8, weekday=WeekDay.SAT), [datetime(2006, 9, 1)] + date_seq_nem_8_sat), (makeFY5253NearestEndMonth(n=1, startingMonth=8, weekday=WeekDay.SAT), [datetime(2006, 9, 3)] + date_seq_nem_8_sat[1:]), (makeFY5253NearestEndMonth(n=-1, startingMonth=8, weekday=WeekDay.SAT), list(reversed(date_seq_nem_8_sat))), (makeFY5253NearestEndMonth(n=1, startingMonth=12, weekday=WeekDay.SUN), JNJ), (makeFY5253NearestEndMonth(n=-1, startingMonth=12, weekday=WeekDay.SUN), list(reversed(JNJ))), (makeFY5253NearestEndMonth(n=1, startingMonth=12, weekday=WeekDay.SUN), [datetime(2005, 1, 2), datetime(2006, 1, 1)]), (makeFY5253NearestEndMonth(n=1, startingMonth=12, weekday=WeekDay.SUN), [datetime(2006, 1, 2), datetime(2006, 12, 31)]), (DEC_SAT, [datetime(2013, 1, 15), datetime(2012, 12, 29)]) ] for test in tests: offset, data = test current = data[0] for datum in data[1:]: current = current + offset assert current == datum
Example #28
Source File: test_fiscal.py From vnpy_crypto with MIT License | 4 votes |
def test_apply(self): date_seq_nem_8_sat = [datetime(2006, 9, 2), datetime(2007, 9, 1), datetime(2008, 8, 30), datetime(2009, 8, 29), datetime(2010, 8, 28), datetime(2011, 9, 3)] JNJ = [datetime(2005, 1, 2), datetime(2006, 1, 1), datetime(2006, 12, 31), datetime(2007, 12, 30), datetime(2008, 12, 28), datetime(2010, 1, 3), datetime(2011, 1, 2), datetime(2012, 1, 1), datetime(2012, 12, 30)] DEC_SAT = FY5253(n=-1, startingMonth=12, weekday=5, variation="nearest") tests = [ (makeFY5253NearestEndMonth(startingMonth=8, weekday=WeekDay.SAT), date_seq_nem_8_sat), (makeFY5253NearestEndMonth(n=1, startingMonth=8, weekday=WeekDay.SAT), date_seq_nem_8_sat), (makeFY5253NearestEndMonth(startingMonth=8, weekday=WeekDay.SAT), [datetime(2006, 9, 1)] + date_seq_nem_8_sat), (makeFY5253NearestEndMonth(n=1, startingMonth=8, weekday=WeekDay.SAT), [datetime(2006, 9, 3)] + date_seq_nem_8_sat[1:]), (makeFY5253NearestEndMonth(n=-1, startingMonth=8, weekday=WeekDay.SAT), list(reversed(date_seq_nem_8_sat))), (makeFY5253NearestEndMonth(n=1, startingMonth=12, weekday=WeekDay.SUN), JNJ), (makeFY5253NearestEndMonth(n=-1, startingMonth=12, weekday=WeekDay.SUN), list(reversed(JNJ))), (makeFY5253NearestEndMonth(n=1, startingMonth=12, weekday=WeekDay.SUN), [datetime(2005, 1, 2), datetime(2006, 1, 1)]), (makeFY5253NearestEndMonth(n=1, startingMonth=12, weekday=WeekDay.SUN), [datetime(2006, 1, 2), datetime(2006, 12, 31)]), (DEC_SAT, [datetime(2013, 1, 15), datetime(2012, 12, 29)]) ] for test in tests: offset, data = test current = data[0] for datum in data[1:]: current = current + offset assert current == datum
Example #29
Source File: test_fiscal.py From coffeegrindsize with MIT License | 4 votes |
def test_apply(self): date_seq_nem_8_sat = [datetime(2006, 9, 2), datetime(2007, 9, 1), datetime(2008, 8, 30), datetime(2009, 8, 29), datetime(2010, 8, 28), datetime(2011, 9, 3)] JNJ = [datetime(2005, 1, 2), datetime(2006, 1, 1), datetime(2006, 12, 31), datetime(2007, 12, 30), datetime(2008, 12, 28), datetime(2010, 1, 3), datetime(2011, 1, 2), datetime(2012, 1, 1), datetime(2012, 12, 30)] DEC_SAT = FY5253(n=-1, startingMonth=12, weekday=5, variation="nearest") tests = [ (makeFY5253NearestEndMonth(startingMonth=8, weekday=WeekDay.SAT), date_seq_nem_8_sat), (makeFY5253NearestEndMonth(n=1, startingMonth=8, weekday=WeekDay.SAT), date_seq_nem_8_sat), (makeFY5253NearestEndMonth(startingMonth=8, weekday=WeekDay.SAT), [datetime(2006, 9, 1)] + date_seq_nem_8_sat), (makeFY5253NearestEndMonth(n=1, startingMonth=8, weekday=WeekDay.SAT), [datetime(2006, 9, 3)] + date_seq_nem_8_sat[1:]), (makeFY5253NearestEndMonth(n=-1, startingMonth=8, weekday=WeekDay.SAT), list(reversed(date_seq_nem_8_sat))), (makeFY5253NearestEndMonth(n=1, startingMonth=12, weekday=WeekDay.SUN), JNJ), (makeFY5253NearestEndMonth(n=-1, startingMonth=12, weekday=WeekDay.SUN), list(reversed(JNJ))), (makeFY5253NearestEndMonth(n=1, startingMonth=12, weekday=WeekDay.SUN), [datetime(2005, 1, 2), datetime(2006, 1, 1)]), (makeFY5253NearestEndMonth(n=1, startingMonth=12, weekday=WeekDay.SUN), [datetime(2006, 1, 2), datetime(2006, 12, 31)]), (DEC_SAT, [datetime(2013, 1, 15), datetime(2012, 12, 29)]) ] for test in tests: offset, data = test current = data[0] for datum in data[1:]: current = current + offset assert current == datum
Example #30
Source File: test_fiscal.py From recruit with Apache License 2.0 | 4 votes |
def test_apply(self): date_seq_nem_8_sat = [datetime(2006, 9, 2), datetime(2007, 9, 1), datetime(2008, 8, 30), datetime(2009, 8, 29), datetime(2010, 8, 28), datetime(2011, 9, 3)] JNJ = [datetime(2005, 1, 2), datetime(2006, 1, 1), datetime(2006, 12, 31), datetime(2007, 12, 30), datetime(2008, 12, 28), datetime(2010, 1, 3), datetime(2011, 1, 2), datetime(2012, 1, 1), datetime(2012, 12, 30)] DEC_SAT = FY5253(n=-1, startingMonth=12, weekday=5, variation="nearest") tests = [ (makeFY5253NearestEndMonth(startingMonth=8, weekday=WeekDay.SAT), date_seq_nem_8_sat), (makeFY5253NearestEndMonth(n=1, startingMonth=8, weekday=WeekDay.SAT), date_seq_nem_8_sat), (makeFY5253NearestEndMonth(startingMonth=8, weekday=WeekDay.SAT), [datetime(2006, 9, 1)] + date_seq_nem_8_sat), (makeFY5253NearestEndMonth(n=1, startingMonth=8, weekday=WeekDay.SAT), [datetime(2006, 9, 3)] + date_seq_nem_8_sat[1:]), (makeFY5253NearestEndMonth(n=-1, startingMonth=8, weekday=WeekDay.SAT), list(reversed(date_seq_nem_8_sat))), (makeFY5253NearestEndMonth(n=1, startingMonth=12, weekday=WeekDay.SUN), JNJ), (makeFY5253NearestEndMonth(n=-1, startingMonth=12, weekday=WeekDay.SUN), list(reversed(JNJ))), (makeFY5253NearestEndMonth(n=1, startingMonth=12, weekday=WeekDay.SUN), [datetime(2005, 1, 2), datetime(2006, 1, 1)]), (makeFY5253NearestEndMonth(n=1, startingMonth=12, weekday=WeekDay.SUN), [datetime(2006, 1, 2), datetime(2006, 12, 31)]), (DEC_SAT, [datetime(2013, 1, 15), datetime(2012, 12, 29)]) ] for test in tests: offset, data = test current = data[0] for datum in data[1:]: current = current + offset assert current == datum