Replace the __future__ imports ...
... with quoted annotations where needed
This commit is contained in:
parent
ef0888619e
commit
cd74b343bc
11 changed files with 18 additions and 40 deletions
|
|
@ -1,7 +1,5 @@
|
||||||
"""Provide the ORM's `Address` model."""
|
"""Provide the ORM's `Address` model."""
|
||||||
|
|
||||||
from __future__ import annotations
|
|
||||||
|
|
||||||
import datetime as dt
|
import datetime as dt
|
||||||
import functools
|
import functools
|
||||||
import typing as t
|
import typing as t
|
||||||
|
|
@ -171,7 +169,7 @@ class Address(meta.Base):
|
||||||
"""
|
"""
|
||||||
return self.location.y
|
return self.location.y
|
||||||
|
|
||||||
def clear_map(self) -> Address: # pragma: no cover
|
def clear_map(self) -> "Address": # pragma: no cover
|
||||||
"""Shortcut to the `.city.clear_map()` method.
|
"""Shortcut to the `.city.clear_map()` method.
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,5 @@
|
||||||
"""Model for the `Path` relationship between two `Address` objects."""
|
"""Model for the `Path` relationship between two `Address` objects."""
|
||||||
|
|
||||||
from __future__ import annotations
|
|
||||||
|
|
||||||
import functools
|
import functools
|
||||||
import itertools
|
import itertools
|
||||||
import json
|
import json
|
||||||
|
|
@ -126,7 +124,7 @@ class Path(meta.Base):
|
||||||
cls,
|
cls,
|
||||||
*addresses: db.Address,
|
*addresses: db.Address,
|
||||||
google_maps: bool = False,
|
google_maps: bool = False,
|
||||||
) -> list[Path]:
|
) -> list["Path"]:
|
||||||
"""Calculate pair-wise paths for `Address` objects.
|
"""Calculate pair-wise paths for `Address` objects.
|
||||||
|
|
||||||
This is the main constructor method for the class.
|
This is the main constructor method for the class.
|
||||||
|
|
@ -183,7 +181,7 @@ class Path(meta.Base):
|
||||||
return paths
|
return paths
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def from_order(cls, order: db.Order, *, google_maps: bool = False) -> Path:
|
def from_order(cls, order: "db.Order", *, google_maps: bool = False) -> "Path":
|
||||||
"""Calculate the path for an `Order` object.
|
"""Calculate the path for an `Order` object.
|
||||||
|
|
||||||
The path goes from the `Order.pickup_address` to the `Order.delivery_address`.
|
The path goes from the `Order.pickup_address` to the `Order.delivery_address`.
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,5 @@
|
||||||
"""Provide the ORM's `City` model."""
|
"""Provide the ORM's `City` model."""
|
||||||
|
|
||||||
from __future__ import annotations
|
|
||||||
|
|
||||||
import functools
|
import functools
|
||||||
|
|
||||||
import folium
|
import folium
|
||||||
|
|
@ -120,7 +118,7 @@ class City(meta.Base):
|
||||||
"""
|
"""
|
||||||
return self.northeast.northing - self.southwest.northing
|
return self.northeast.northing - self.southwest.northing
|
||||||
|
|
||||||
def clear_map(self) -> City: # pragma: no cover
|
def clear_map(self) -> "City": # pragma: no cover
|
||||||
"""Create a new `folium.Map` object aligned with the city's viewport.
|
"""Create a new `folium.Map` object aligned with the city's viewport.
|
||||||
|
|
||||||
The map is available via the `.map` property. Note that it is mutable
|
The map is available via the `.map` property. Note that it is mutable
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,5 @@
|
||||||
"""Provide the ORM's `Customer` model."""
|
"""Provide the ORM's `Customer` model."""
|
||||||
|
|
||||||
from __future__ import annotations
|
|
||||||
|
|
||||||
import folium
|
import folium
|
||||||
import sqlalchemy as sa
|
import sqlalchemy as sa
|
||||||
from sqlalchemy import orm
|
from sqlalchemy import orm
|
||||||
|
|
@ -30,7 +28,7 @@ class Customer(meta.Base):
|
||||||
# Relationships
|
# Relationships
|
||||||
orders = orm.relationship("Order", back_populates="customer")
|
orders = orm.relationship("Order", back_populates="customer")
|
||||||
|
|
||||||
def clear_map(self) -> Customer: # pragma: no cover
|
def clear_map(self) -> "Customer": # pragma: no cover
|
||||||
"""Shortcut to the `...city.clear_map()` method.
|
"""Shortcut to the `...city.clear_map()` method.
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,5 @@
|
||||||
"""Provide the ORM's `Forecast` model."""
|
"""Provide the ORM's `Forecast` model."""
|
||||||
|
|
||||||
from __future__ import annotations
|
|
||||||
|
|
||||||
import datetime as dt
|
import datetime as dt
|
||||||
import math
|
import math
|
||||||
|
|
||||||
|
|
@ -187,12 +185,12 @@ class Forecast(meta.Base):
|
||||||
@classmethod
|
@classmethod
|
||||||
def from_dataframe(
|
def from_dataframe(
|
||||||
cls,
|
cls,
|
||||||
pixel: db.Pixel,
|
pixel: "db.Pixel",
|
||||||
time_step: int,
|
time_step: int,
|
||||||
train_horizon: int,
|
train_horizon: int,
|
||||||
model: str,
|
model: str,
|
||||||
data: pd.DataFrame,
|
data: pd.DataFrame,
|
||||||
) -> list[db.Forecast]:
|
) -> list["db.Forecast"]:
|
||||||
"""Convert results from the forecasting `*Model`s into `Forecast` objects.
|
"""Convert results from the forecasting `*Model`s into `Forecast` objects.
|
||||||
|
|
||||||
This is an alternative constructor method.
|
This is an alternative constructor method.
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,5 @@
|
||||||
"""Provide the ORM's `Grid` model."""
|
"""Provide the ORM's `Grid` model."""
|
||||||
|
|
||||||
from __future__ import annotations
|
|
||||||
|
|
||||||
import typing as t
|
import typing as t
|
||||||
|
|
||||||
import folium
|
import folium
|
||||||
|
|
@ -67,7 +65,7 @@ class Grid(meta.Base):
|
||||||
return round((self.side_length**2) / 1_000_000, 1)
|
return round((self.side_length**2) / 1_000_000, 1)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def gridify(cls, city: db.City, side_length: int) -> db.Grid:
|
def gridify(cls, city: db.City, side_length: int) -> "db.Grid":
|
||||||
"""Create a fully populated `Grid` for a `city`.
|
"""Create a fully populated `Grid` for a `city`.
|
||||||
|
|
||||||
The `Grid` contains only `Pixel`s that have at least one
|
The `Grid` contains only `Pixel`s that have at least one
|
||||||
|
|
@ -122,7 +120,7 @@ class Grid(meta.Base):
|
||||||
|
|
||||||
return grid
|
return grid
|
||||||
|
|
||||||
def clear_map(self) -> Grid: # pragma: no cover
|
def clear_map(self) -> "Grid": # pragma: no cover
|
||||||
"""Shortcut to the `.city.clear_map()` method.
|
"""Shortcut to the `.city.clear_map()` method.
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,5 @@
|
||||||
"""Provide the ORM's `Pixel` model."""
|
"""Provide the ORM's `Pixel` model."""
|
||||||
|
|
||||||
from __future__ import annotations
|
|
||||||
|
|
||||||
import functools
|
import functools
|
||||||
|
|
||||||
import folium
|
import folium
|
||||||
|
|
@ -130,7 +128,7 @@ class Pixel(meta.Base):
|
||||||
return location
|
return location
|
||||||
|
|
||||||
@functools.cached_property
|
@functools.cached_property
|
||||||
def restaurants(self) -> list[db.Restaurant]: # pragma: no cover
|
def restaurants(self) -> list["db.Restaurant"]: # pragma: no cover
|
||||||
"""Obtain all `Restaurant`s in `self`."""
|
"""Obtain all `Restaurant`s in `self`."""
|
||||||
return (
|
return (
|
||||||
db.session.query(db.Restaurant)
|
db.session.query(db.Restaurant)
|
||||||
|
|
@ -142,7 +140,7 @@ class Pixel(meta.Base):
|
||||||
.all()
|
.all()
|
||||||
)
|
)
|
||||||
|
|
||||||
def clear_map(self) -> Pixel: # pragma: no cover
|
def clear_map(self) -> "Pixel": # pragma: no cover
|
||||||
"""Shortcut to the `.city.clear_map()` method.
|
"""Shortcut to the `.city.clear_map()` method.
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,5 @@
|
||||||
"""Provide the ORM's `ReplayedOrder` model for the replay simulations."""
|
"""Provide the ORM's `ReplayedOrder` model for the replay simulations."""
|
||||||
|
|
||||||
from __future__ import annotations
|
|
||||||
|
|
||||||
import datetime as dt
|
import datetime as dt
|
||||||
|
|
||||||
import sqlalchemy as sa
|
import sqlalchemy as sa
|
||||||
|
|
@ -409,22 +407,22 @@ class ReplayedOrder(meta.Base):
|
||||||
# Convenience properties
|
# Convenience properties
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def customer(self) -> db.Customer:
|
def customer(self) -> "db.Customer":
|
||||||
"""`.customer` of the actual `Order`."""
|
"""`.customer` of the actual `Order`."""
|
||||||
return self.actual.customer
|
return self.actual.customer
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def restaurant(self) -> db.Restaurant:
|
def restaurant(self) -> "db.Restaurant":
|
||||||
"""`.restaurant` of the actual `Order`."""
|
"""`.restaurant` of the actual `Order`."""
|
||||||
return self.actual.restaurant
|
return self.actual.restaurant
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def pickup_address(self) -> db.Address:
|
def pickup_address(self) -> "db.Address":
|
||||||
"""`.pickup_address` of the actual `Order`."""
|
"""`.pickup_address` of the actual `Order`."""
|
||||||
return self.actual.pickup_address
|
return self.actual.pickup_address
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def delivery_address(self) -> db.Address:
|
def delivery_address(self) -> "db.Address":
|
||||||
"""`.delivery_address` of the actual `Order`."""
|
"""`.delivery_address` of the actual `Order`."""
|
||||||
return self.actual.delivery_address
|
return self.actual.delivery_address
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,5 @@
|
||||||
"""Provide the ORM's `Restaurant` model."""
|
"""Provide the ORM's `Restaurant` model."""
|
||||||
|
|
||||||
from __future__ import annotations
|
|
||||||
|
|
||||||
import datetime as dt
|
import datetime as dt
|
||||||
|
|
||||||
import folium
|
import folium
|
||||||
|
|
@ -75,7 +73,7 @@ class Restaurant(meta.Base):
|
||||||
"""Non-literal text representation."""
|
"""Non-literal text representation."""
|
||||||
return f"<{self.__class__.__name__}({self.name})>"
|
return f"<{self.__class__.__name__}({self.name})>"
|
||||||
|
|
||||||
def clear_map(self) -> Restaurant: # pragma: no cover
|
def clear_map(self) -> "Restaurant": # pragma: no cover
|
||||||
"""Shortcut to the `.address.city.clear_map()` method.
|
"""Shortcut to the `.address.city.clear_map()` method.
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,5 @@
|
||||||
"""A `Location` class to unify working with coordinates."""
|
"""A `Location` class to unify working with coordinates."""
|
||||||
|
|
||||||
from __future__ import annotations
|
|
||||||
|
|
||||||
import utm
|
import utm
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -132,7 +130,7 @@ class Location:
|
||||||
|
|
||||||
return self._normalized_northing
|
return self._normalized_northing
|
||||||
|
|
||||||
def relate_to(self, other: Location) -> None:
|
def relate_to(self, other: "Location") -> None:
|
||||||
"""Make the origin in the lower-left corner relative to `other`.
|
"""Make the origin in the lower-left corner relative to `other`.
|
||||||
|
|
||||||
The `.x` and `.y` properties are the `.easting` and `.northing` values
|
The `.x` and `.y` properties are the `.easting` and `.northing` values
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,5 @@
|
||||||
"""Obtain and work with time series data."""
|
"""Obtain and work with time series data."""
|
||||||
|
|
||||||
from __future__ import annotations
|
|
||||||
|
|
||||||
import datetime as dt
|
import datetime as dt
|
||||||
import typing as t
|
import typing as t
|
||||||
|
|
||||||
|
|
@ -566,7 +564,7 @@ class OrderHistory:
|
||||||
pixel_id: int,
|
pixel_id: int,
|
||||||
predict_day: dt.date,
|
predict_day: dt.date,
|
||||||
train_horizon: int,
|
train_horizon: int,
|
||||||
) -> models.ForecastingModelABC:
|
) -> "models.ForecastingModelABC":
|
||||||
"""Choose the most promising forecasting `*Model` for tactical purposes.
|
"""Choose the most promising forecasting `*Model` for tactical purposes.
|
||||||
|
|
||||||
The rules are deduced from "Table 1: Top-3 models by ..." in the article
|
The rules are deduced from "Table 1: Top-3 models by ..." in the article
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue