コード例 #1
0
 def check(date):
     if not re.match('^[0-9]{4}-[0-9]{2}-[0-9]{2}$', date):
         raise Exception("Invalid product date value: {}".format(date))
     start = md.to_ordinal(md.startdate(acquired))
     end = md.to_ordinal(md.enddate(acquired))
     val = md.to_ordinal(date)
     if val < start or val > end:
         raise Exception("Product date {} out of range{}".format(
             date, acquired))
コード例 #2
0
def changedate(rdd):

    return safely(func=fp.changedate,
                  kwargs={
                      'models': result_to_models(rdd['data']),
                      'ord_date': dates.to_ordinal(rdd['datestr'])
                  },
                  x=rdd['x'],
                  y=rdd['y'],
                  chip_x=rdd['chip_x'],
                  chip_y=rdd['chip_y'],
                  alg=algorithm('changedate', fp.version),
                  datestr=rdd['datestr'],
                  error=rdd['error'])
コード例 #3
0
def curveqa(rdd):

    chip_x = rdd[0][0][0]
    chip_y = rdd[0][0][1]
    x = rdd[0][0][2]
    y = rdd[0][0][3]
    data = rdd[0][1]
    errs = rdd[0][2]
    date = rdd[1]
    kwargs = {
        'models': result_to_models(data),
        'ord_date': dates.to_ordinal(date)
    }

    return safely(func=fp.curveqa,
                  kwargs=kwargs,
                  x=x,
                  y=y,
                  chip_x=chip_x,
                  chip_y=chip_y,
                  alg=algorithm('curveqa', fp.version),
                  datestr=date,
                  errors=errs)
コード例 #4
0
def test_changemag():
    ord_date = d.to_ordinal("1984-04-01")
    assert products.changemag([{'change_probability': 1, 'break_day': ord_date}], ord_date) == 0.0
コード例 #5
0
def test_qa():
    assert products.curveqa([{'start_day': d.to_ordinal("1986-04-01"),
                              'end_day': d.to_ordinal("1988-07-01"),
                              'curve_qa': 999}],
                             d.to_ordinal('1987-01-01')) == 999
コード例 #6
0
def test_seglength():
    assert products.seglength([{'start_day': d.to_ordinal("1986-04-01"),
                                'end_day': d.to_ordinal("1988-07-01")}],
                              d.to_ordinal("1984-04-01"),
                              bot=d.to_ordinal("1982-01-01")) == 821
コード例 #7
0
def test_to_ordinal():
    assert dates.to_ordinal('1999-01-01') == 729755
    assert dates.to_ordinal('1999/11/01') == 730059