コード例 #1
0
def timeindex():
    outd = dict(
        start="2020-01-01T00:00:00+00:00",
        end="2020-12-31T23:59:59+00:00",
        step="15:00",
        timezone="UTC",
    )
    return outd, models.JobTimeindex(**outd)
コード例 #2
0
def test_jobtimeindex(start, end, tz):
    out = models.JobTimeindex(start=start, end=end, step="15:00", timezone=tz)
    assert out.step == dt.timedelta(minutes=15)
    assert out.timezone == "UTC"
    pd.testing.assert_index_equal(
        out._time_range,
        pd.date_range(
            start="2020-01-01T00:00:00",
            end="2020-12-31T23:59:59",
            freq="15min",
            tz="UTC",
        ),
    )
コード例 #3
0
def new_job(system_id):
    return models.CalculatePerformanceJobParameters(
        system_id=system_id,
        calculate="expected performance",
        time_parameters=models.JobTimeindex(
            start="2020-01-01T00:00:00+00:00",
            end="2020-12-31T23:59:59+00:00",
            step="15:00",
            timezone="UTC",
        ),
        weather_granularity="system",
        irradiance_type="poa",
        temperature_type="module",
    )
コード例 #4
0
def test_jobtimeindex_validation(start, end, step, tz):
    with pytest.raises(ValidationError):
        models.JobTimeindex(start=start, end=end, step=step, timezone=tz)
コード例 #5
0
def test_jobtimeindex(start, end, tz, exp):
    out = models.JobTimeindex(start=start, end=end, step="15:00", timezone=tz)
    assert out.step == dt.timedelta(minutes=15)
    assert out.timezone == tz or "UTC"
    pd.testing.assert_index_equal(out._time_range, exp)
コード例 #6
0
def test_reindex_timeseries(inp, jti, exp_df, exp_extra, exp_missing):
    new, extra, missing = utils.reindex_timeseries(inp,
                                                   models.JobTimeindex(**jti))
    pd.testing.assert_frame_equal(new, exp_df)
    assert extra == exp_extra
    assert missing == exp_missing
コード例 #7
0
def test_reindex_shifting(inp, exp, jti, ats):
    inpdf = pd.DataFrame({"time": inp, "other": list(range(len(inp)))})
    out = utils.reindex_timeseries(inpdf, models.JobTimeindex(**jti), ats)[0]
    pd.testing.assert_frame_equal(out, exp)