Use double quotes

This commit is contained in:
Alexander Hess 2026-11-28 03:08:55 +01:00
commit ea8f1a13e3
Signed by: alexander
GPG key ID: B46EDB4DFC26805D
8 changed files with 2464 additions and 2466 deletions

View file

@ -21,11 +21,11 @@ def horizontal_datetime_index():
gen = (
start_at
for start_at in pd.date_range(first_start_at, test_config.END, freq='D')
for start_at in pd.date_range(first_start_at, test_config.END, freq="D")
)
index = pd.Index(gen)
index.name = 'start_at'
index.name = "start_at"
# Sanity check.
# `+1` as both the `START` and `END` day are included.
@ -38,7 +38,7 @@ def horizontal_datetime_index():
@pytest.fixture
def horizontal_no_demand(horizontal_datetime_index):
"""A horizontal time series with order totals: no demand."""
return pd.Series(0, index=horizontal_datetime_index, name='n_orders')
return pd.Series(0, index=horizontal_datetime_index, name="n_orders")
@pytest.fixture
@ -52,7 +52,7 @@ def vertical_datetime_index():
start_ats = pd.date_range(
test_config.START,
test_config.END,
freq=f'{test_config.LONG_TIME_STEP}min',
freq=f"{test_config.LONG_TIME_STEP}min",
)
gen = (
start_at
@ -61,7 +61,7 @@ def vertical_datetime_index():
)
index = pd.Index(gen)
index.name = 'start_at'
index.name = "start_at"
# Sanity check: n_days * n_number_of_opening_hours.
# `+1` as both the `START` and `END` day are included.
@ -74,7 +74,7 @@ def vertical_datetime_index():
@pytest.fixture
def vertical_no_demand(vertical_datetime_index):
"""A vertical time series with order totals: no demand."""
return pd.Series(0, index=vertical_datetime_index, name='n_orders')
return pd.Series(0, index=vertical_datetime_index, name="n_orders")
@pytest.fixture
@ -107,7 +107,7 @@ def order_totals(good_pixel_id):
start_ats = pd.date_range(
test_config.START,
test_config.END,
freq=f'{test_config.LONG_TIME_STEP}min',
freq=f"{test_config.LONG_TIME_STEP}min",
)
gen = (
(pixel_id, start_at)
@ -118,9 +118,9 @@ def order_totals(good_pixel_id):
# Re-index `data` filling in `0`s where there is no demand.
index = pd.MultiIndex.from_tuples(gen)
index.names = ['pixel_id', 'start_at']
index.names = ["pixel_id", "start_at"]
df = pd.DataFrame(data={'n_orders': 1}, index=index)
df = pd.DataFrame(data={"n_orders": 1}, index=index)
# Sanity check: n_pixels * n_time_steps_per_day * n_days.
# `+1` as both the `START` and `END` day are included.

View file

@ -20,7 +20,7 @@ class TestInvalidArguments:
"""`stl()` requires a `time_series` without `NaN` values."""
time_series = pd.Series(dtype=float, index=vertical_datetime_index)
with pytest.raises(ValueError, match='`NaN` values'):
with pytest.raises(ValueError, match="`NaN` values"):
decomposition.stl(
time_series,
frequency=test_config.VERTICAL_FREQUENCY_LONG,
@ -29,17 +29,17 @@ class TestInvalidArguments:
def test_ns_not_odd(self, vertical_no_demand):
"""`ns` must be odd and `>= 7`."""
with pytest.raises(ValueError, match='`ns`'):
with pytest.raises(ValueError, match="`ns`"):
decomposition.stl(
vertical_no_demand,
frequency=test_config.VERTICAL_FREQUENCY_LONG,
ns=8,
)
@pytest.mark.parametrize('ns', [-99, -1, 1, 5])
@pytest.mark.parametrize("ns", [-99, -1, 1, 5])
def test_ns_smaller_than_seven(self, vertical_no_demand, ns):
"""`ns` must be odd and `>= 7`."""
with pytest.raises(ValueError, match='`ns`'):
with pytest.raises(ValueError, match="`ns`"):
decomposition.stl(
vertical_no_demand,
frequency=test_config.VERTICAL_FREQUENCY_LONG,
@ -55,7 +55,7 @@ class TestInvalidArguments:
assert nt > default_nt # sanity check
with pytest.raises(ValueError, match='`nt`'):
with pytest.raises(ValueError, match="`nt`"):
decomposition.stl(
vertical_no_demand,
frequency=test_config.VERTICAL_FREQUENCY_LONG,
@ -63,7 +63,7 @@ class TestInvalidArguments:
nt=nt,
)
@pytest.mark.parametrize('nt', [-99, -1, 0, 1, 99, 125])
@pytest.mark.parametrize("nt", [-99, -1, 0, 1, 99, 125])
def test_nt_not_at_least_the_default(self, vertical_no_demand, nt):
"""`nt` must be odd and `>= default_nt`."""
# `default_nt` becomes 161.
@ -73,7 +73,7 @@ class TestInvalidArguments:
assert nt < default_nt # sanity check
with pytest.raises(ValueError, match='`nt`'):
with pytest.raises(ValueError, match="`nt`"):
decomposition.stl(
vertical_no_demand,
frequency=test_config.VERTICAL_FREQUENCY_LONG,
@ -87,7 +87,7 @@ class TestInvalidArguments:
assert nl > test_config.VERTICAL_FREQUENCY_LONG # sanity check
with pytest.raises(ValueError, match='`nl`'):
with pytest.raises(ValueError, match="`nl`"):
decomposition.stl(
vertical_no_demand,
frequency=test_config.VERTICAL_FREQUENCY_LONG,
@ -101,7 +101,7 @@ class TestInvalidArguments:
assert nl < test_config.VERTICAL_FREQUENCY_LONG # sanity check
with pytest.raises(ValueError, match='`nl`'):
with pytest.raises(ValueError, match="`nl`"):
decomposition.stl(
vertical_no_demand,
frequency=test_config.VERTICAL_FREQUENCY_LONG,
@ -111,7 +111,7 @@ class TestInvalidArguments:
def test_ds_not_zero_or_one(self, vertical_no_demand):
"""`ds` must be `0` or `1`."""
with pytest.raises(ValueError, match='`ds`'):
with pytest.raises(ValueError, match="`ds`"):
decomposition.stl(
vertical_no_demand,
frequency=test_config.VERTICAL_FREQUENCY_LONG,
@ -121,7 +121,7 @@ class TestInvalidArguments:
def test_dt_not_zero_or_one(self, vertical_no_demand):
"""`dt` must be `0` or `1`."""
with pytest.raises(ValueError, match='`dt`'):
with pytest.raises(ValueError, match="`dt`"):
decomposition.stl(
vertical_no_demand,
frequency=test_config.VERTICAL_FREQUENCY_LONG,
@ -131,7 +131,7 @@ class TestInvalidArguments:
def test_dl_not_zero_or_one(self, vertical_no_demand):
"""`dl` must be `0` or `1`."""
with pytest.raises(ValueError, match='`dl`'):
with pytest.raises(ValueError, match="`dl`"):
decomposition.stl(
vertical_no_demand,
frequency=test_config.VERTICAL_FREQUENCY_LONG,
@ -139,10 +139,10 @@ class TestInvalidArguments:
dl=2,
)
@pytest.mark.parametrize('js', [-1, 0])
@pytest.mark.parametrize("js", [-1, 0])
def test_js_not_positive(self, vertical_no_demand, js):
"""`js` must be positive."""
with pytest.raises(ValueError, match='`js`'):
with pytest.raises(ValueError, match="`js`"):
decomposition.stl(
vertical_no_demand,
frequency=test_config.VERTICAL_FREQUENCY_LONG,
@ -150,10 +150,10 @@ class TestInvalidArguments:
js=js,
)
@pytest.mark.parametrize('jt', [-1, 0])
@pytest.mark.parametrize("jt", [-1, 0])
def test_jt_not_positive(self, vertical_no_demand, jt):
"""`jt` must be positive."""
with pytest.raises(ValueError, match='`jt`'):
with pytest.raises(ValueError, match="`jt`"):
decomposition.stl(
vertical_no_demand,
frequency=test_config.VERTICAL_FREQUENCY_LONG,
@ -161,10 +161,10 @@ class TestInvalidArguments:
jt=jt,
)
@pytest.mark.parametrize('jl', [-1, 0])
@pytest.mark.parametrize("jl", [-1, 0])
def test_jl_not_positive(self, vertical_no_demand, jl):
"""`jl` must be positive."""
with pytest.raises(ValueError, match='`jl`'):
with pytest.raises(ValueError, match="`jl`"):
decomposition.stl(
vertical_no_demand,
frequency=test_config.VERTICAL_FREQUENCY_LONG,
@ -172,10 +172,10 @@ class TestInvalidArguments:
jl=jl,
)
@pytest.mark.parametrize('ni', [-1, 0])
@pytest.mark.parametrize("ni", [-1, 0])
def test_ni_not_positive(self, vertical_no_demand, ni):
"""`ni` must be positive."""
with pytest.raises(ValueError, match='`ni`'):
with pytest.raises(ValueError, match="`ni`"):
decomposition.stl(
vertical_no_demand,
frequency=test_config.VERTICAL_FREQUENCY_LONG,
@ -185,7 +185,7 @@ class TestInvalidArguments:
def test_no_not_non_negative(self, vertical_no_demand):
"""`no` must be non-negative."""
with pytest.raises(ValueError, match='`no`'):
with pytest.raises(ValueError, match="`no`"):
decomposition.stl(
vertical_no_demand,
frequency=test_config.VERTICAL_FREQUENCY_LONG,
@ -207,20 +207,20 @@ class TestValidArguments:
)
assert isinstance(result, pd.DataFrame)
assert list(result.columns) == ['seasonal', 'trend', 'residual']
assert list(result.columns) == ["seasonal", "trend", "residual"]
# Run the `stl()` function with all possible combinations of arguments,
# including default ones and explicitly set non-default ones.
@pytest.mark.parametrize('nt', [None, 163])
@pytest.mark.parametrize('nl', [None, 777])
@pytest.mark.parametrize('ds', [0, 1])
@pytest.mark.parametrize('dt', [0, 1])
@pytest.mark.parametrize('dl', [0, 1])
@pytest.mark.parametrize('js', [None, 1])
@pytest.mark.parametrize('jt', [None, 1])
@pytest.mark.parametrize('jl', [None, 1])
@pytest.mark.parametrize('ni', [2, 3])
@pytest.mark.parametrize('no', [0, 1])
@pytest.mark.parametrize("nt", [None, 163])
@pytest.mark.parametrize("nl", [None, 777])
@pytest.mark.parametrize("ds", [0, 1])
@pytest.mark.parametrize("dt", [0, 1])
@pytest.mark.parametrize("dl", [0, 1])
@pytest.mark.parametrize("js", [None, 1])
@pytest.mark.parametrize("jt", [None, 1])
@pytest.mark.parametrize("jl", [None, 1])
@pytest.mark.parametrize("ni", [2, 3])
@pytest.mark.parametrize("no", [0, 1])
def test_decompose_time_series_with_no_demand(
self,
vertical_no_demand,

View file

@ -38,7 +38,7 @@ def forecast_interval():
start_ats = pd.date_range(
first_start_at,
end_of_day,
freq=f'{test_config.LONG_TIME_STEP}min',
freq=f"{test_config.LONG_TIME_STEP}min",
)
gen = (
start_at
@ -47,7 +47,7 @@ def forecast_interval():
)
index = pd.Index(gen)
index.name = 'start_at'
index.name = "start_at"
return index
@ -66,14 +66,14 @@ def forecast_time_step():
)
index = pd.Index([start_at])
index.name = 'start_at'
index.name = "start_at"
return index
@pytest.mark.r
@pytest.mark.parametrize(
'func',
"func",
[arima.predict, ets.predict, extrapolate_season.predict],
)
class TestMakePredictions:
@ -88,7 +88,7 @@ class TestMakePredictions:
"""`training_ts` must not contain `NaN` values."""
vertical_no_demand.iloc[0] = pd.NA
with pytest.raises(ValueError, match='must not contain `NaN`'):
with pytest.raises(ValueError, match="must not contain `NaN`"):
func(
training_ts=vertical_no_demand,
forecast_interval=forecast_interval,
@ -110,11 +110,11 @@ class TestMakePredictions:
assert isinstance(result, pd.DataFrame)
assert list(result.columns) == [
'prediction',
'low80',
'high80',
'low95',
'high95',
"prediction",
"low80",
"high80",
"low95",
"high95",
]
def test_predict_horizontal_time_series_with_no_demand(

View file

@ -17,7 +17,7 @@ MODELS = (
)
@pytest.mark.parametrize('model_cls', MODELS)
@pytest.mark.parametrize("model_cls", MODELS)
class TestGenericForecastingModelProperties:
"""Test everything all concrete `*Model`s have in common.
@ -81,12 +81,12 @@ class TestGenericForecastingModelProperties:
assert isinstance(result, pd.DataFrame)
assert list(result.columns) == [
'actual',
'prediction',
'low80',
'high80',
'low95',
'high95',
"actual",
"prediction",
"low80",
"high80",
"low95",
"high95",
]
@pytest.mark.r
@ -131,8 +131,8 @@ class TestGenericForecastingModelProperties:
train_horizon=test_config.LONG_TRAIN_HORIZON,
)
assert not result['actual'].isnull().any()
assert not result['prediction'].isnull().any()
assert not result["actual"].isnull().any()
assert not result["prediction"].isnull().any()
@pytest.mark.db
@pytest.mark.r

View file

@ -29,7 +29,7 @@ class TestAggregateOrders:
query = (
mock.query.return_value.join.return_value.filter.return_value.all # noqa:E501
)
monkeypatch.setattr(db, 'session', mock)
monkeypatch.setattr(db, "session", mock)
return query
@ -95,9 +95,9 @@ class TestAggregateOrders:
# The resulting `DataFrame` has 12 rows holding `1`s.
assert len(result) == 12
assert result['n_orders'].min() == 1
assert result['n_orders'].max() == 1
assert result['n_orders'].sum() == 12
assert result["n_orders"].min() == 1
assert result["n_orders"].max() == 1
assert result["n_orders"].sum() == 12
def test_evenly_distributed_ad_hoc_orders_with_no_demand_late(
self,
@ -130,10 +130,10 @@ class TestAggregateOrders:
# Even though there are only 10 orders, there are 12 rows in the `DataFrame`.
# That is so as `0`s are filled in for hours without any demand at the end.
assert len(result) == 12
assert result['n_orders'].min() == 0
assert result['n_orders'].max() == 1
assert result.iloc[:10]['n_orders'].sum() == 10
assert result.iloc[10:]['n_orders'].sum() == 0
assert result["n_orders"].min() == 0
assert result["n_orders"].max() == 1
assert result.iloc[:10]["n_orders"].sum() == 10
assert result.iloc[10:]["n_orders"].sum() == 0
def test_one_ad_hoc_order_every_other_hour(
self,
@ -165,9 +165,9 @@ class TestAggregateOrders:
# The resulting `DataFrame` has 12 rows, 6 holding `0`s, and 6 holding `1`s.
assert len(result) == 12
assert result['n_orders'].min() == 0
assert result['n_orders'].max() == 1
assert result['n_orders'].sum() == 6
assert result["n_orders"].min() == 0
assert result["n_orders"].max() == 1
assert result["n_orders"].sum() == 6
def test_one_ad_hoc_and_one_pre_order(
self,
@ -208,9 +208,9 @@ class TestAggregateOrders:
# The resulting `DataFrame` has 12 rows, 11 holding `0`s, and one holding a `1`.
assert len(result) == 12
assert result['n_orders'].min() == 0
assert result['n_orders'].max() == 1
assert result['n_orders'].sum() == 1
assert result["n_orders"].min() == 0
assert result["n_orders"].max() == 1
assert result["n_orders"].sum() == 1
def test_evenly_distributed_ad_hoc_orders_with_half_hour_time_steps(
self,
@ -246,10 +246,10 @@ class TestAggregateOrders:
# The resulting `DataFrame` has 24 rows for the 24 30-minute time steps.
# The rows' values are `0` and `1` alternating.
assert len(result) == 24
assert result['n_orders'].min() == 0
assert result['n_orders'].max() == 1
assert result.iloc[::2]['n_orders'].sum() == 12
assert result.iloc[1::2]['n_orders'].sum() == 0
assert result["n_orders"].min() == 0
assert result["n_orders"].max() == 1
assert result.iloc[::2]["n_orders"].sum() == 12
assert result.iloc[1::2]["n_orders"].sum() == 0
def test_ad_hoc_orders_over_two_days(
self,
@ -300,9 +300,9 @@ class TestAggregateOrders:
# The resulting `DataFrame` has 24 rows, 12 for each day.
assert len(result) == 24
assert result['n_orders'].min() == 0
assert result['n_orders'].max() == 1
assert result['n_orders'].sum() == 18
assert result["n_orders"].min() == 0
assert result["n_orders"].max() == 1
assert result["n_orders"].sum() == 18
@pytest.fixture
def two_pixel_grid(
@ -403,6 +403,6 @@ class TestAggregateOrders:
# The resulting `DataFrame` has 24 rows, 12 for each pixel.
assert len(result) == 24
assert result['n_orders'].min() == 0
assert result['n_orders'].max() == 2
assert result['n_orders'].sum() == 30
assert result["n_orders"].min() == 0
assert result["n_orders"].max() == 2
assert result["n_orders"].sum() == 30

View file

@ -43,7 +43,7 @@ class TestAverageDailyDemand:
predict_at,
):
"""Without demand, the average daily demand must be `0.0`."""
order_history._data.loc[:, 'n_orders'] = 0
order_history._data.loc[:, "n_orders"] = 0
result = order_history.avg_daily_demand(
pixel_id=good_pixel_id,
@ -65,7 +65,7 @@ class TestChooseTacticalModel:
):
"""With high demand, the average daily demand is `.>= 25.0`."""
# With 12 time steps per day, the ADD becomes `36.0`.
order_history._data.loc[:, 'n_orders'] = 3
order_history._data.loc[:, "n_orders"] = 3
result = order_history.choose_tactical_model(
pixel_id=good_pixel_id,
@ -83,7 +83,7 @@ class TestChooseTacticalModel:
):
"""With medium demand, the average daily demand is `>= 10.0` and `< 25.0`."""
# With 12 time steps per day, the ADD becomes `24.0`.
order_history._data.loc[:, 'n_orders'] = 2
order_history._data.loc[:, "n_orders"] = 2
result = order_history.choose_tactical_model(
pixel_id=good_pixel_id,
@ -102,23 +102,23 @@ class TestChooseTacticalModel:
"""With low demand, the average daily demand is `>= 2.5` and `< 10.0`."""
# With 12 time steps per day, the ADD becomes `12.0` ...
data = order_history._data
data.loc[:, 'n_orders'] = 1
data.loc[:, "n_orders"] = 1
# ... and we set three additional time steps per day to `0`.
data.loc[
# all `Pixel`s, all `Order`s in time steps starting at 11 am
(slice(None), slice(data.index.levels[1][0], None, 12)),
'n_orders',
"n_orders",
] = 0
data.loc[
# all `Pixel`s, all `Order`s in time steps starting at 12 am
(slice(None), slice(data.index.levels[1][1], None, 12)),
'n_orders',
"n_orders",
] = 0
data.loc[
# all `Pixel`s, all `Order`s in time steps starting at 1 pm
(slice(None), slice(data.index.levels[1][2], None, 12)),
'n_orders',
"n_orders",
] = 0
result = order_history.choose_tactical_model(
@ -136,7 +136,7 @@ class TestChooseTacticalModel:
predict_at,
):
"""Without demand, the average daily demand is `< 2.5`."""
order_history._data.loc[:, 'n_orders'] = 0
order_history._data.loc[:, "n_orders"] = 0
result = order_history.choose_tactical_model(
pixel_id=good_pixel_id,
@ -156,7 +156,7 @@ class TestChooseTacticalModel:
... the method raises a `RuntimeError`.
"""
with pytest.raises(RuntimeError, match='no rule'):
with pytest.raises(RuntimeError, match="no rule"):
order_history.choose_tactical_model(
pixel_id=good_pixel_id,
predict_day=predict_at.date(),

View file

@ -49,7 +49,7 @@ def bad_predict_at():
class TestMakeHorizontalTimeSeries:
"""Test the `OrderHistory.make_horizontal_ts()` method."""
@pytest.mark.parametrize('train_horizon', test_config.TRAIN_HORIZONS)
@pytest.mark.parametrize("train_horizon", test_config.TRAIN_HORIZONS)
def test_wrong_pixel(self, order_history, good_predict_at, train_horizon):
"""A `pixel_id` that is not in the `grid`."""
with pytest.raises(LookupError):
@ -59,7 +59,7 @@ class TestMakeHorizontalTimeSeries:
train_horizon=train_horizon,
)
@pytest.mark.parametrize('train_horizon', test_config.TRAIN_HORIZONS)
@pytest.mark.parametrize("train_horizon", test_config.TRAIN_HORIZONS)
def test_time_series_are_series(
self,
order_history,
@ -77,11 +77,11 @@ class TestMakeHorizontalTimeSeries:
training_ts, _, actuals_ts = result
assert isinstance(training_ts, pd.Series)
assert training_ts.name == 'n_orders'
assert training_ts.name == "n_orders"
assert isinstance(actuals_ts, pd.Series)
assert actuals_ts.name == 'n_orders'
assert actuals_ts.name == "n_orders"
@pytest.mark.parametrize('train_horizon', test_config.TRAIN_HORIZONS)
@pytest.mark.parametrize("train_horizon", test_config.TRAIN_HORIZONS)
def test_time_series_have_correct_length(
self,
order_history,
@ -104,7 +104,7 @@ class TestMakeHorizontalTimeSeries:
assert len(training_ts) == 7 * train_horizon
assert len(actuals_ts) == 1
@pytest.mark.parametrize('train_horizon', test_config.TRAIN_HORIZONS)
@pytest.mark.parametrize("train_horizon", test_config.TRAIN_HORIZONS)
def test_frequency_is_number_of_weekdays(
self,
order_history,
@ -123,7 +123,7 @@ class TestMakeHorizontalTimeSeries:
assert frequency == 7
@pytest.mark.parametrize('train_horizon', test_config.TRAIN_HORIZONS)
@pytest.mark.parametrize("train_horizon", test_config.TRAIN_HORIZONS)
def test_no_long_enough_history1(
self,
order_history,
@ -163,7 +163,7 @@ class TestMakeHorizontalTimeSeries:
class TestMakeVerticalTimeSeries:
"""Test the `OrderHistory.make_vertical_ts()` method."""
@pytest.mark.parametrize('train_horizon', test_config.TRAIN_HORIZONS)
@pytest.mark.parametrize("train_horizon", test_config.TRAIN_HORIZONS)
def test_wrong_pixel(self, order_history, good_predict_at, train_horizon):
"""A `pixel_id` that is not in the `grid`."""
with pytest.raises(LookupError):
@ -173,7 +173,7 @@ class TestMakeVerticalTimeSeries:
train_horizon=train_horizon,
)
@pytest.mark.parametrize('train_horizon', test_config.TRAIN_HORIZONS)
@pytest.mark.parametrize("train_horizon", test_config.TRAIN_HORIZONS)
def test_time_series_are_series(
self,
order_history,
@ -191,11 +191,11 @@ class TestMakeVerticalTimeSeries:
training_ts, _, actuals_ts = result
assert isinstance(training_ts, pd.Series)
assert training_ts.name == 'n_orders'
assert training_ts.name == "n_orders"
assert isinstance(actuals_ts, pd.Series)
assert actuals_ts.name == 'n_orders'
assert actuals_ts.name == "n_orders"
@pytest.mark.parametrize('train_horizon', test_config.TRAIN_HORIZONS)
@pytest.mark.parametrize("train_horizon", test_config.TRAIN_HORIZONS)
def test_time_series_have_correct_length(
self,
order_history,
@ -228,7 +228,7 @@ class TestMakeVerticalTimeSeries:
assert len(training_ts) == 7 * n_daily_time_steps * train_horizon
assert len(actuals_ts) == n_daily_time_steps
@pytest.mark.parametrize('train_horizon', test_config.TRAIN_HORIZONS)
@pytest.mark.parametrize("train_horizon", test_config.TRAIN_HORIZONS)
def test_frequency_is_number_number_of_weekly_time_steps(
self,
order_history,
@ -253,7 +253,7 @@ class TestMakeVerticalTimeSeries:
assert frequency == 7 * n_daily_time_steps
@pytest.mark.parametrize('train_horizon', test_config.TRAIN_HORIZONS)
@pytest.mark.parametrize("train_horizon", test_config.TRAIN_HORIZONS)
def test_no_long_enough_history1(
self,
order_history,
@ -293,7 +293,7 @@ class TestMakeVerticalTimeSeries:
class TestMakeRealTimeTimeSeries:
"""Test the `OrderHistory.make_realtime_ts()` method."""
@pytest.mark.parametrize('train_horizon', test_config.TRAIN_HORIZONS)
@pytest.mark.parametrize("train_horizon", test_config.TRAIN_HORIZONS)
def test_wrong_pixel(self, order_history, good_predict_at, train_horizon):
"""A `pixel_id` that is not in the `grid`."""
with pytest.raises(LookupError):
@ -303,7 +303,7 @@ class TestMakeRealTimeTimeSeries:
train_horizon=train_horizon,
)
@pytest.mark.parametrize('train_horizon', test_config.TRAIN_HORIZONS)
@pytest.mark.parametrize("train_horizon", test_config.TRAIN_HORIZONS)
def test_time_series_are_series(
self,
order_history,
@ -321,11 +321,11 @@ class TestMakeRealTimeTimeSeries:
training_ts, _, actuals_ts = result
assert isinstance(training_ts, pd.Series)
assert training_ts.name == 'n_orders'
assert training_ts.name == "n_orders"
assert isinstance(actuals_ts, pd.Series)
assert actuals_ts.name == 'n_orders'
assert actuals_ts.name == "n_orders"
@pytest.mark.parametrize('train_horizon', test_config.TRAIN_HORIZONS)
@pytest.mark.parametrize("train_horizon", test_config.TRAIN_HORIZONS)
def test_time_series_have_correct_length1(
self,
order_history,
@ -365,7 +365,7 @@ class TestMakeRealTimeTimeSeries:
assert len(training_ts) == 7 * n_daily_time_steps * train_horizon
assert len(actuals_ts) == 1
@pytest.mark.parametrize('train_horizon', test_config.TRAIN_HORIZONS)
@pytest.mark.parametrize("train_horizon", test_config.TRAIN_HORIZONS)
def test_time_series_have_correct_length2(
self,
order_history,
@ -408,7 +408,7 @@ class TestMakeRealTimeTimeSeries:
)
assert len(actuals_ts) == 1
@pytest.mark.parametrize('train_horizon', test_config.TRAIN_HORIZONS)
@pytest.mark.parametrize("train_horizon", test_config.TRAIN_HORIZONS)
def test_frequency_is_number_number_of_weekly_time_steps(
self,
order_history,
@ -433,7 +433,7 @@ class TestMakeRealTimeTimeSeries:
assert frequency == 7 * n_daily_time_steps
@pytest.mark.parametrize('train_horizon', test_config.TRAIN_HORIZONS)
@pytest.mark.parametrize("train_horizon", test_config.TRAIN_HORIZONS)
def test_no_long_enough_history1(
self,
order_history,

View file

@ -19,7 +19,7 @@ class TestSpecialMethods:
class TestProperties:
"""Test the properties in `OrderHistory`."""
@pytest.mark.parametrize('time_step', test_config.TIME_STEPS)
@pytest.mark.parametrize("time_step", test_config.TIME_STEPS)
def test_time_step(self, grid, time_step):
"""Test `OrderHistory.time_step` property."""
order_history = timify.OrderHistory(grid=grid, time_step=time_step)
@ -50,9 +50,9 @@ class TestProperties:
Note: We make `OrderHistory.aggregate_orders()` return a `sentinel`
that is cached into `OrderHistory._data`, which must be unset first.
"""
monkeypatch.setattr(order_history, '_data', None)
monkeypatch.setattr(order_history, "_data", None)
sentinel = object()
monkeypatch.setattr(order_history, 'aggregate_orders', lambda: sentinel)
monkeypatch.setattr(order_history, "aggregate_orders", lambda: sentinel)
result1 = order_history.totals
result2 = order_history.totals
@ -74,7 +74,7 @@ class TestMethods:
"""Test `OrderHistory.first_order_at()` with bad input."""
with pytest.raises(
LookupError,
match='`pixel_id` is not in the `grid`',
match="`pixel_id` is not in the `grid`",
):
order_history.first_order_at(-1)
@ -89,6 +89,6 @@ class TestMethods:
"""Test `OrderHistory.last_order_at()` with bad input."""
with pytest.raises(
LookupError,
match='`pixel_id` is not in the `grid`',
match="`pixel_id` is not in the `grid`",
):
order_history.last_order_at(-1)