def _steps(self, tmfrspec_dict, options=dict()): """Given dict of FrameSpec attrs, return list of steps.""" tmfrspec = framespec.FrameSpec(**tmfrspec_dict) step1 = stepper.Stepper(tmfrspec) for o, v in options.iteritems(): step1.set_option(o, v) steps = list(step1.steps()) # print "steps=", len(steps), "\n", "\n".join([str(s) for s in steps]) return steps
def test_str(self, dts): tmfrspec_dict = { 'range_unit': 'MONTH', 'range_val': 1, 'gran_unit': 'DAY', 'mode': 'CURRENT', } frspec = framespec.FrameSpec(**tmfrspec_dict) step1 = stepper.Stepper(frspec) str(step1)
def test_ghosts_complex(self, dts): tmfrspec_dict = { 'range_unit': 'DAY', 'range_val': 7, 'gran_unit': 'DAY', 'mode': 'CURRENT', 'reframe_dt': dt('2014-02-14 16:30:45 001234'), } tmfrspec = framespec.FrameSpec(**tmfrspec_dict) # steps = list(stepper.Stepper(tmfrspec, ghost=None).steps()) assert len(steps) == 7 assert steps[0].anchor == dt('2014-02-08 00:00:00 000000') # g1 = ghost.Ghost('PREV_PERIOD1') steps = list(stepper.Stepper(tmfrspec, ghost=g1).steps()) assert steps[0].anchor == dt('2014-02-01 00:00:00 000000') # g1 = ghost.Ghost('PREV_PERIOD2') steps = list(stepper.Stepper(tmfrspec, ghost=g1).steps()) assert steps[0].anchor == dt('2014-01-25 00:00:00 000000')
def test_ghosts(self, dts): tmfrspec_dict = { 'range_unit': 'QUARTER', 'range_val': 1, 'gran_unit': 'WEEK', 'smooth_unit': 'DAY', 'smooth_val': 14, 'mode': 'CURRENT', 'reframe_dt': dt('2014-02-14 16:30:45 001234'), } tmfrspec = framespec.FrameSpec(**tmfrspec_dict) # steps = list(stepper.Stepper(tmfrspec, ghost=None).steps()) assert steps[0].anchor == dt('2014-01-01 00:00:00 000000') # g1 = "Not a Ghost" with pytest.raises(TypeError): steps = list(stepper.Stepper(tmfrspec, ghost=g1).steps()) # g1 = ghost.Ghost('PREV_PERIOD1') str(g1) steps = list(stepper.Stepper(tmfrspec, ghost=g1).steps()) assert steps[0].anchor == dt('2013-10-01 00:00:00 000000') # g1 = ghost.Ghost('PREV_PERIOD2') steps = list(stepper.Stepper(tmfrspec, ghost=g1).steps()) assert steps[0].anchor == dt('2013-07-01 00:00:00 000000') # g1 = ghost.Ghost('PREV_YEAR1') steps = list(stepper.Stepper(tmfrspec, ghost=g1).steps()) assert steps[0].anchor == dt('2013-01-01 00:00:00 000000') # g1 = ghost.Ghost('PREV_YEAR2') steps = list(stepper.Stepper(tmfrspec, ghost=g1).steps()) assert steps[0].anchor == dt('2012-01-01 00:00:00 000000')
def test_impl_error_smooth_unit(self, tmfrspecs): tmfrspecs[1]._smooth_unit = 'BOGUS' with pytest.raises(ValueError): list(stepper.Stepper(tmfrspecs[1]).steps())
def test_impl_error_base_ok(self, tmfrspecs): list(stepper.Stepper(tmfrspecs[1]).steps())