Break multi-line comments before conjunctions
This commit is contained in:
parent
049a5f6f62
commit
2f1afd459f
11 changed files with 27 additions and 27 deletions
|
|
@ -305,8 +305,8 @@ class Path(meta.Base):
|
||||||
# the `.waypoints` are not available
|
# the `.waypoints` are not available
|
||||||
self.sync_with_google_maps()
|
self.sync_with_google_maps()
|
||||||
|
|
||||||
# First, plot the couriers' path between the start and
|
# First, plot the couriers' path between the start and end locations,
|
||||||
# end locations, so that it is below the `folium.Circle`s
|
# so that it is below the `folium.Circle`s
|
||||||
line = folium.PolyLine(
|
line = folium.PolyLine(
|
||||||
locations=(
|
locations=(
|
||||||
self.first_address.location.lat_lng,
|
self.first_address.location.lat_lng,
|
||||||
|
|
|
||||||
|
|
@ -69,8 +69,8 @@ class Customer(meta.Base):
|
||||||
# Note: a `Customer` may have more than one delivery `Address`es.
|
# Note: a `Customer` may have more than one delivery `Address`es.
|
||||||
# That is not true for `Restaurant`s after the data cleaning.
|
# That is not true for `Restaurant`s after the data cleaning.
|
||||||
|
|
||||||
# Obtain all primary `Address`es where
|
# Obtain all primary `Address`es
|
||||||
# at least one delivery was made to `self`
|
# where at least one delivery was made to `self`
|
||||||
delivery_addresses = db.session.scalars(
|
delivery_addresses = db.session.scalars(
|
||||||
sa.select(db.Address).where(
|
sa.select(db.Address).where(
|
||||||
db.Address.id.in_(
|
db.Address.id.in_(
|
||||||
|
|
|
||||||
|
|
@ -50,8 +50,8 @@ class Forecast(meta.Base):
|
||||||
nullable=False,
|
nullable=False,
|
||||||
)
|
)
|
||||||
# We also store the actual order counts for convenient retrieval.
|
# We also store the actual order counts for convenient retrieval.
|
||||||
# A `UniqueConstraint` below ensures that redundant values that
|
# A `UniqueConstraint` below ensures that redundant values
|
||||||
# are to be expected are consistent across rows.
|
# that are to be expected are consistent across rows.
|
||||||
actual: orm.Mapped[int] = orm.mapped_column(
|
actual: orm.Mapped[int] = orm.mapped_column(
|
||||||
sa.SmallInteger,
|
sa.SmallInteger,
|
||||||
nullable=False,
|
nullable=False,
|
||||||
|
|
|
||||||
|
|
@ -216,8 +216,8 @@ class ReplayedOrder(meta.Base):
|
||||||
sa.CheckConstraint(
|
sa.CheckConstraint(
|
||||||
# A simulation must fill in at least all the timing and dispatch related
|
# A simulation must fill in at least all the timing and dispatch related
|
||||||
# columns, unless an order is cancelled in a run.
|
# columns, unless an order is cancelled in a run.
|
||||||
# Only `.estimated_prep_duration`, `.first_estimated_delivery_at`, and
|
# Only `.estimated_prep_duration`, `.first_estimated_delivery_at`,
|
||||||
# `.utilization` are truly optional.
|
# and `.utilization` are truly optional.
|
||||||
# This constraint does allow missing columns for cancelled orders
|
# This constraint does allow missing columns for cancelled orders
|
||||||
# in any combination of the below columns. So, no precedence constraints
|
# in any combination of the below columns. So, no precedence constraints
|
||||||
# are enforced (e.g., `.restaurant_notified_at` and `.restaurant_ready_at`
|
# are enforced (e.g., `.restaurant_notified_at` and `.restaurant_ready_at`
|
||||||
|
|
@ -326,8 +326,8 @@ class ReplayedOrder(meta.Base):
|
||||||
name="orders_dispatched_in_business_hours",
|
name="orders_dispatched_in_business_hours",
|
||||||
),
|
),
|
||||||
*(
|
*(
|
||||||
# The timestamps must be in a logically correct order. That is the same as
|
# The timestamps must be in a logically correct order. That is the same
|
||||||
# in the actual `Order` model with an extra `restaurant_ready_at` column
|
# as in the actual `Order` model with an extra `restaurant_ready_at` column
|
||||||
# and the non-simulated columns removed.
|
# and the non-simulated columns removed.
|
||||||
sa.CheckConstraint(
|
sa.CheckConstraint(
|
||||||
constraint,
|
constraint,
|
||||||
|
|
|
||||||
|
|
@ -110,8 +110,8 @@ class Restaurant(meta.Base):
|
||||||
`.address.city.map` for convenience in interactive usage
|
`.address.city.map` for convenience in interactive usage
|
||||||
"""
|
"""
|
||||||
if customers:
|
if customers:
|
||||||
# Obtain all primary `Address`es in the city that
|
# Obtain all primary `Address`es in the city
|
||||||
# received at least one delivery from `self`
|
# that received at least one delivery from `self`
|
||||||
delivery_addresses = db.session.scalars(
|
delivery_addresses = db.session.scalars(
|
||||||
sa.select(db.Address).where(
|
sa.select(db.Address).where(
|
||||||
db.Address.id.in_(
|
db.Address.id.in_(
|
||||||
|
|
|
||||||
|
|
@ -44,8 +44,8 @@ def predict(
|
||||||
seasonal_lag = frequency * (training_ts.index[1] - training_ts.index[0])
|
seasonal_lag = frequency * (training_ts.index[1] - training_ts.index[0])
|
||||||
|
|
||||||
for lag in range(frequency):
|
for lag in range(frequency):
|
||||||
# Obtain all `observations` of the same seasonal lag and
|
# Obtain all `observations` of the same seasonal lag
|
||||||
# fit a straight line through them (= `trend`)
|
# and fit a straight line through them (= `trend`)
|
||||||
observations = training_ts[slice(lag, 999_999_999, frequency)]
|
observations = training_ts[slice(lag, 999_999_999, frequency)]
|
||||||
trend = observations - tsa.detrend(observations)
|
trend = observations - tsa.detrend(observations)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -93,8 +93,8 @@ class ForecastingModelABC(abc.ABC):
|
||||||
return cached_forecast
|
return cached_forecast
|
||||||
|
|
||||||
# Horizontal and real-time `*Model`s return a `pd.DataFrame` with one
|
# Horizontal and real-time `*Model`s return a `pd.DataFrame` with one
|
||||||
# row corresponding to the time step starting at `predict_at` whereas
|
# row corresponding to the time step starting at `predict_at`
|
||||||
# vertical models return several rows, covering all time steps of a day
|
# whereas vertical models return several rows, covering all time steps of a day
|
||||||
predictions = self.predict(pixel, predict_at, train_horizon)
|
predictions = self.predict(pixel, predict_at, train_horizon)
|
||||||
|
|
||||||
# Convert the `predictions` into a `list` of `Forecast` objects
|
# Convert the `predictions` into a `list` of `Forecast` objects
|
||||||
|
|
|
||||||
|
|
@ -30,9 +30,9 @@ def test_two_pixels_with_two_addresses(
|
||||||
# ... and another one in the upper-right one.
|
# ... and another one in the upper-right one.
|
||||||
address2 = make_address(latitude=48.8898312, longitude=2.4357622)
|
address2 = make_address(latitude=48.8898312, longitude=2.4357622)
|
||||||
|
|
||||||
# Locate a `Restaurant` at the two `Address` objects and
|
# Locate a `Restaurant` at the two `Address`es
|
||||||
# place one `Order` for each of them so that the `Address`
|
# and place one `Order` for each of them
|
||||||
# objects are used as `Order.pickup_address`s
|
# so that the `Address`es are used as `Order.pickup_address`es
|
||||||
restaurant1 = make_restaurant(address=address1)
|
restaurant1 = make_restaurant(address=address1)
|
||||||
restaurant2 = make_restaurant(address=address2)
|
restaurant2 = make_restaurant(address=address2)
|
||||||
order1 = make_order(restaurant=restaurant1)
|
order1 = make_order(restaurant=restaurant1)
|
||||||
|
|
|
||||||
|
|
@ -21,8 +21,8 @@ class AddressFactory(alchemy.SQLAlchemyModelFactory):
|
||||||
created_at = factory.LazyFunction(utils.early_in_the_morning)
|
created_at = factory.LazyFunction(utils.early_in_the_morning)
|
||||||
|
|
||||||
# When testing, all addresses are considered primary ones.
|
# When testing, all addresses are considered primary ones.
|
||||||
# As non-primary addresses have no different behavior and
|
# As non-primary addresses have no different behavior
|
||||||
# the property is only kept from the original dataset for
|
# and the property is only kept from the original dataset for
|
||||||
# completeness sake, that is ok to do.
|
# completeness sake, that is ok to do.
|
||||||
primary_id = factory.LazyAttribute(lambda obj: obj.id)
|
primary_id = factory.LazyAttribute(lambda obj: obj.id)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -384,8 +384,8 @@ class TestSyncWithGoogleMaps:
|
||||||
"legs": [
|
"legs": [
|
||||||
{
|
{
|
||||||
# We choose an artificially high distance of `9999`
|
# We choose an artificially high distance of `9999`
|
||||||
# so that the synced bicycle distance is longer than
|
# so that the synced bicycle distance is longer
|
||||||
# the randomized air distance (i.e., fake data) for sure
|
# than the randomized air distance (i.e., fake data) for sure
|
||||||
"distance": {"text": "3.0 km", "value": 9999},
|
"distance": {"text": "3.0 km", "value": 9999},
|
||||||
"duration": {"text": "10 mins", "value": 596},
|
"duration": {"text": "10 mins", "value": 596},
|
||||||
"end_address": "13 Place Paul et Jean Paul Avisseau, ...",
|
"end_address": "13 Place Paul et Jean Paul Avisseau, ...",
|
||||||
|
|
|
||||||
|
|
@ -100,8 +100,8 @@ class TestConstraints:
|
||||||
with pytest.raises(sa_exc.IntegrityError, match="fk_orders_to_restaurants"):
|
with pytest.raises(sa_exc.IntegrityError, match="fk_orders_to_restaurants"):
|
||||||
db_session.commit()
|
db_session.commit()
|
||||||
|
|
||||||
# Here should be a test to check deletion of a referenced pickup address, so
|
# Here should be a test to check deletion of a referenced pickup address,
|
||||||
# `test_delete_a_referenced_pickup_address(self, db_session, order)`.
|
# so `test_delete_a_referenced_pickup_address(self, db_session, order)`.
|
||||||
# The corresponding "fk_orders_to_addresses_on_pickup_address_id" constraint
|
# The corresponding "fk_orders_to_addresses_on_pickup_address_id" constraint
|
||||||
# is very hard to test in isolation as the above "fk_orders_to_restaurants_..."
|
# is very hard to test in isolation as the above "fk_orders_to_restaurants_..."
|
||||||
# constraint ensures its integrity already.
|
# constraint ensures its integrity already.
|
||||||
|
|
@ -1167,8 +1167,8 @@ def test_make_random_orders(
|
||||||
# Ad-hoc `Order`s are far more common than pre-orders
|
# Ad-hoc `Order`s are far more common than pre-orders
|
||||||
scheduled = random.choice([True, False, False, False, False])
|
scheduled = random.choice([True, False, False, False, False])
|
||||||
|
|
||||||
# Randomly pass a `address` argument to `make_restaurant()` and
|
# Randomly pass a `address` argument to `make_restaurant()`
|
||||||
# a `restaurant` argument to `make_order()`
|
# and a `restaurant` argument to `make_order()`
|
||||||
if random.random() < 0.5:
|
if random.random() < 0.5:
|
||||||
address = random.choice([None, make_address()])
|
address = random.choice([None, make_address()])
|
||||||
restaurant = make_restaurant(address=address)
|
restaurant = make_restaurant(address=address)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue