Reword the comments in the rest of velofy

Each comment is one sentence or two short ones
joined by "=>", without a final period.
This commit is contained in:
Alexander Hess 2026-12-03 10:46:24 +01:00
commit 0f69709226
Signed by: alexander
GPG key ID: B46EDB4DFC26805D
3 changed files with 13 additions and 18 deletions

View file

@ -38,17 +38,16 @@ class Config:
SERVICE_START = 11
SERVICE_END = 23
# Side lengths (in meters) for which pixel grids are created.
# They are the basis for the aggregated demand forecasts.
# Side lengths (in meters) of the pixel grids
# => They are the basis for the aggregated demand forecasts
GRID_SIDE_LENGTHS = (707, 1000, 1414)
# Time steps (in minutes) used to aggregate the
# individual orders into time series
TIME_STEPS = (60,)
# Training horizons (in full weeks) used to train the forecasting models.
# For now, we only use 7 and 8 weeks as that was the best performing in
# a previous study (note:4f79e8fa).
# Training horizons (in full weeks) for the forecasting models
# => 7 and 8 weeks performed best in a previous study (note:4f79e8fa)
TRAIN_HORIZONS = (7, 8)
# The demand forecasting methods used in the simulations
@ -118,19 +117,16 @@ def make_config(env: str = "production") -> Config:
msg = "Must be either 'production' or 'testing'"
raise ValueError(msg)
# Without a PostgreSQL database the package cannot work.
# As pytest sets the "TESTING" environment variable explicitly,
# the warning is only emitted if the code is not run by pytest.
# We see the bad configuration immediately as all "db" tests fail.
# pytest sets `TESTING` and fails all "db" tests without a database anyway
# => Warn only outside pytest
if config.DATABASE_URI is None and not os.getenv("TESTING"):
warnings.warn(
"Bad configuration: no DATABASE_URI set in the environment",
stacklevel=2,
)
# Some functionalities require R and some packages installed.
# To ensure isolation and reproducibility, the projects keeps the R dependencies
# in a project-local folder that must be set in the environment.
# The R packages live in a project-local folder for isolation and reproducibility
# => Its path must be set in the environment
if config.R_LIBS_PATH is None and not os.getenv("TESTING"):
warnings.warn(
"Bad configuration: no R_LIBS set in the environment",

View file

@ -103,9 +103,8 @@ def tactical_heuristic( # noqa:C901,D417,DOC001
# Run the tactical heuristic
for pixel in grid.pixels:
# Important: this check may need to be adapted once further
# commands are added the make `Forecast`s without the heuristic!
# Continue with forecasting on the day the last prediction was made ...
# Continue on the day of the last prediction ...
# (assuming that no other command makes `Forecast`s)
last_predict_at = db.session.scalar(
sa.select(sa.func.max(db.Forecast.start_at))
.join(db.Pixel, db.Forecast.pixel_id == db.Pixel.id)
@ -116,7 +115,7 @@ def tactical_heuristic( # noqa:C901,D417,DOC001
.where(db.Forecast.train_horizon == train_horizon),
)
# ... or start `train_horizon` weeks after the first `Order`
# if no `Forecast`s are in the database yet.
# if no `Forecast`s are in the database yet
if last_predict_at is None:
predict_day = order_history.first_order_at(pixel_id=pixel.id).date()
predict_day += dt.timedelta(weeks=train_horizon)
@ -125,7 +124,7 @@ def tactical_heuristic( # noqa:C901,D417,DOC001
# Go over all days in chronological order ...
while predict_day <= order_history.last_order_at(pixel_id=pixel.id).date():
# ... and choose the most promising `*Model` for that day.
# ... and choose the most promising `*Model` for that day
model = order_history.choose_tactical_model(
pixel_id=pixel.id,
predict_day=predict_day,

View file

@ -11,7 +11,7 @@ from rpy2.rinterface_lib import callbacks as r_callbacks
from rpy2.robjects import packages as r_packages
# Suppress R's messages to stdout and stderr.
# R's console messages would clutter the output => Suppress them
# Source: https://stackoverflow.com/a/63220287
r_callbacks.consolewrite_print = lambda *_args, **_kwargs: None # pragma: no cover
r_callbacks.consolewrite_warnerror = lambda *_args, **_kwargs: None # pragma: no cover