Remove all "WPS" codes
This commit is contained in:
parent
8a5a652b3e
commit
9fcb3c8c14
26 changed files with 171 additions and 254 deletions
|
|
@ -16,7 +16,7 @@ def db_revision(
|
|||
|
||||
def decorator(func: Callable[..., Any]) -> Callable[..., Any]:
|
||||
@functools.wraps(func)
|
||||
def ensure(*args: Any, **kwargs: Any) -> Any: # noqa:WPS430
|
||||
def ensure(*args: Any, **kwargs: Any) -> Any:
|
||||
"""Do not execute the `func` if the revision does not match."""
|
||||
if not os.getenv('TESTING'):
|
||||
result = subprocess.run( # noqa:S603,S607
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ from velofy.forecasts import timify
|
|||
@click.argument('time_step', default=60, type=int)
|
||||
@click.argument('train_horizon', default=8, type=int)
|
||||
@decorators.db_revision('8bfb928a31f8')
|
||||
def tactical_heuristic( # noqa:C901,WPS213,WPS216
|
||||
def tactical_heuristic( # noqa:C901
|
||||
city: str,
|
||||
side_length: int,
|
||||
time_step: int,
|
||||
|
|
@ -68,9 +68,7 @@ def tactical_heuristic( # noqa:C901,WPS213,WPS216
|
|||
# Input validation.
|
||||
|
||||
try:
|
||||
city_obj = (
|
||||
db.session.query(db.City).filter_by(name=city.title()).one() # noqa:WPS221
|
||||
)
|
||||
city_obj = db.session.query(db.City).filter_by(name=city.title()).one()
|
||||
except orm_exc.NoResultFound:
|
||||
click.echo('NAME must be one of "Paris", "Lyon", or "Bordeaux"')
|
||||
sys.exit(1)
|
||||
|
|
@ -97,17 +95,17 @@ def tactical_heuristic( # noqa:C901,WPS213,WPS216
|
|||
)
|
||||
|
||||
# Load the historic order data.
|
||||
order_history = timify.OrderHistory(grid=grid, time_step=time_step) # noqa:WPS441
|
||||
order_history = timify.OrderHistory(grid=grid, time_step=time_step)
|
||||
order_history.aggregate_orders()
|
||||
|
||||
# Run the tactical heuristic.
|
||||
|
||||
for pixel in grid.pixels: # noqa:WPS441
|
||||
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 ...
|
||||
last_predict_at = (
|
||||
db.session.query(func.max(db.Forecast.start_at)) # noqa:WPS221
|
||||
db.session.query(func.max(db.Forecast.start_at))
|
||||
.join(db.Pixel, db.Forecast.pixel_id == db.Pixel.id)
|
||||
.join(db.Grid, db.Pixel.grid_id == db.Grid.id)
|
||||
.filter(db.Forecast.pixel == pixel)
|
||||
|
|
|
|||
|
|
@ -16,8 +16,8 @@ def show_version(ctx: cli_core.Context, _param: Any, value: bool) -> None:
|
|||
return
|
||||
|
||||
# Mimic the colors of `poetry version`.
|
||||
pkg_name = click.style(velofy.__pkg_name__, fg='green') # noqa:WPS609
|
||||
version = click.style(velofy.__version__, fg='blue') # noqa:WPS609
|
||||
pkg_name = click.style(velofy.__pkg_name__, fg='green')
|
||||
version = click.style(velofy.__version__, fg='blue')
|
||||
# Include a warning for development versions.
|
||||
warning = click.style(' (development)', fg='red') if '.dev' in version else ''
|
||||
click.echo(f'{pkg_name}, version {version}{warning}')
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ class Address(meta.Base):
|
|||
__tablename__ = 'addresses'
|
||||
|
||||
# Columns
|
||||
id = sa.Column(sa.Integer, primary_key=True, autoincrement=False) # noqa:WPS125
|
||||
id = sa.Column(sa.Integer, primary_key=True, autoincrement=False)
|
||||
primary_id = sa.Column(sa.Integer, nullable=False, index=True)
|
||||
created_at = sa.Column(sa.DateTime, nullable=False)
|
||||
place_id = sa.Column(sa.Unicode(length=120), nullable=False, index=True)
|
||||
|
|
@ -116,7 +116,7 @@ class Address(meta.Base):
|
|||
return location
|
||||
|
||||
@property
|
||||
def x(self) -> int: # noqa=WPS111
|
||||
def x(self) -> int:
|
||||
"""The relative x-coordinate within the `.city` in meters.
|
||||
|
||||
On the implied x-y plane, the `.city`'s southwest corner is the origin.
|
||||
|
|
@ -126,7 +126,7 @@ class Address(meta.Base):
|
|||
return self.location.x
|
||||
|
||||
@property
|
||||
def y(self) -> int: # noqa=WPS111
|
||||
def y(self) -> int:
|
||||
"""The relative y-coordinate within the `.city` in meters.
|
||||
|
||||
On the implied x-y plane, the `.city`'s southwest corner is the origin.
|
||||
|
|
@ -145,7 +145,7 @@ class Address(meta.Base):
|
|||
return self
|
||||
|
||||
@property # pragma: no cover
|
||||
def map(self) -> folium.Map: # noqa:WPS125
|
||||
def map(self) -> folium.Map:
|
||||
"""Shortcut to the `.city.map` object."""
|
||||
return self.city.map
|
||||
|
||||
|
|
|
|||
|
|
@ -128,9 +128,7 @@ class Path(meta.Base):
|
|||
# We consider all 2-tuples of `Address`es. The symmetric graph is ...
|
||||
for first, second in itertools.combinations(addresses, 2):
|
||||
# ... implicitly enforced by a precedence constraint for the `.id`s.
|
||||
first, second = ( # noqa:WPS211
|
||||
(first, second) if first.id < second.id else (second, first)
|
||||
)
|
||||
first, second = (first, second) if first.id < second.id else (second, first)
|
||||
|
||||
# If there is no `Path` object in the database ...
|
||||
path = (
|
||||
|
|
@ -158,7 +156,7 @@ class Path(meta.Base):
|
|||
paths.append(path)
|
||||
|
||||
if google_maps:
|
||||
for path in paths: # noqa:WPS440
|
||||
for path in paths:
|
||||
path.sync_with_google_maps()
|
||||
|
||||
return paths
|
||||
|
|
@ -212,8 +210,8 @@ class Path(meta.Base):
|
|||
# Source: https://developers.google.com/maps/documentation/directions/get-directions#Legs # noqa:E501
|
||||
route = response[0]['legs'][0]
|
||||
|
||||
self.bicycle_distance = route['distance']['value'] # noqa:WPS601
|
||||
self.bicycle_duration = route['duration']['value'] # noqa:WPS601
|
||||
self.bicycle_distance = route['distance']['value']
|
||||
self.bicycle_duration = route['duration']['value']
|
||||
|
||||
# Each route consists of many "steps" that are instructions as to how to
|
||||
# get from A to B. As a step's "start_location" may equal the previous step's
|
||||
|
|
@ -221,23 +219,23 @@ class Path(meta.Base):
|
|||
# pairs that make up the path from `.first_address` to `.second_address`.
|
||||
steps: ordered_set.OrderedSet[Tuple[float, float]] = ordered_set.OrderedSet()
|
||||
for step in route['steps']:
|
||||
steps.add( # noqa:WPS221
|
||||
steps.add(
|
||||
(step['start_location']['lat'], step['start_location']['lng']),
|
||||
)
|
||||
steps.add( # noqa:WPS221
|
||||
steps.add(
|
||||
(step['end_location']['lat'], step['end_location']['lng']),
|
||||
)
|
||||
|
||||
steps.discard(self.first_address.location.lat_lng)
|
||||
steps.discard(self.second_address.location.lat_lng)
|
||||
|
||||
self._directions = json.dumps(list(steps)) # noqa:WPS601
|
||||
self._directions = json.dumps(list(steps))
|
||||
|
||||
db.session.add(self)
|
||||
db.session.commit()
|
||||
|
||||
@property # pragma: no cover
|
||||
def map(self) -> folium.Map: # noqa:WPS125
|
||||
def map(self) -> folium.Map:
|
||||
"""Convenience property to obtain the underlying `City.map`."""
|
||||
return self.first_address.city.map
|
||||
|
||||
|
|
@ -256,7 +254,7 @@ class Path(meta.Base):
|
|||
|
||||
return points
|
||||
|
||||
def draw( # noqa:WPS211
|
||||
def draw(
|
||||
self,
|
||||
*,
|
||||
reverse: bool = False,
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ class City(meta.Base):
|
|||
__tablename__ = 'cities'
|
||||
|
||||
# Generic columns
|
||||
id = sa.Column( # noqa:WPS125
|
||||
id = sa.Column(
|
||||
sa.SmallInteger,
|
||||
primary_key=True,
|
||||
autoincrement=False,
|
||||
|
|
@ -110,12 +110,12 @@ class City(meta.Base):
|
|||
return self
|
||||
|
||||
@property # pragma: no cover
|
||||
def map(self) -> folium.Map: # noqa:WPS125
|
||||
def map(self) -> folium.Map:
|
||||
"""A `folium.Map` object aligned with the city's viewport.
|
||||
|
||||
See docstring for `.clear_map()` for further info.
|
||||
"""
|
||||
if not hasattr(self, '_map'): # noqa:WPS421 note:d334120e
|
||||
if not hasattr(self, '_map'): # note:d334120e
|
||||
self.clear_map()
|
||||
|
||||
return self._map
|
||||
|
|
@ -137,7 +137,7 @@ class City(meta.Base):
|
|||
db.session.query(db.Address)
|
||||
.filter(
|
||||
db.Address.id.in_(
|
||||
db.session.query(db.Address.primary_id) # noqa:WPS221
|
||||
db.session.query(db.Address.primary_id)
|
||||
.join(db.Restaurant, db.Address.id == db.Restaurant.address_id)
|
||||
.filter(db.Address.city == self)
|
||||
.distinct()
|
||||
|
|
@ -157,9 +157,9 @@ class City(meta.Base):
|
|||
.all()
|
||||
)
|
||||
if len(restaurants) == 1:
|
||||
tooltip = f'{restaurants[0].name} (#{restaurants[0].id})' # noqa:WPS221
|
||||
tooltip = f'{restaurants[0].name} (#{restaurants[0].id})'
|
||||
else:
|
||||
tooltip = 'Restaurants ' + ', '.join( # noqa:WPS336
|
||||
tooltip = 'Restaurants ' + ', '.join(
|
||||
f'#{restaurant.id}' for restaurant in restaurants
|
||||
)
|
||||
|
||||
|
|
@ -183,7 +183,7 @@ class City(meta.Base):
|
|||
else:
|
||||
radius = 1
|
||||
|
||||
tooltip += f' | n_orders={n_orders}' # noqa:WPS336
|
||||
tooltip += f' | n_orders={n_orders}'
|
||||
|
||||
address.draw(
|
||||
radius=radius,
|
||||
|
|
@ -239,7 +239,7 @@ class City(meta.Base):
|
|||
if not address.is_primary:
|
||||
continue
|
||||
|
||||
marker = folium.Circle( # noqa:WPS317
|
||||
marker = folium.Circle(
|
||||
(address.latitude, address.longitude),
|
||||
color=colors[address.zip_code],
|
||||
radius=1,
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ class Courier(meta.Base):
|
|||
__tablename__ = 'couriers'
|
||||
|
||||
# Columns
|
||||
id = sa.Column(sa.Integer, primary_key=True, autoincrement=False) # noqa:WPS125
|
||||
id = sa.Column(sa.Integer, primary_key=True, autoincrement=False)
|
||||
created_at = sa.Column(sa.DateTime, nullable=False)
|
||||
vehicle = sa.Column(sa.Unicode(length=10), nullable=False)
|
||||
historic_speed = sa.Column('speed', postgresql.DOUBLE_PRECISION, nullable=False)
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ class Customer(meta.Base):
|
|||
__tablename__ = 'customers'
|
||||
|
||||
# Columns
|
||||
id = sa.Column(sa.Integer, primary_key=True, autoincrement=False) # noqa:WPS125
|
||||
id = sa.Column(sa.Integer, primary_key=True, autoincrement=False)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""Non-literal text representation."""
|
||||
|
|
@ -35,15 +35,15 @@ class Customer(meta.Base):
|
|||
Returns:
|
||||
self: enabling method chaining
|
||||
""" # noqa:D402,DAR203
|
||||
self.orders[0].pickup_address.city.clear_map() # noqa:WPS219
|
||||
self.orders[0].pickup_address.city.clear_map()
|
||||
return self
|
||||
|
||||
@property # pragma: no cover
|
||||
def map(self) -> folium.Map: # noqa:WPS125
|
||||
def map(self) -> folium.Map:
|
||||
"""Shortcut to the `...city.map` object."""
|
||||
return self.orders[0].pickup_address.city.map # noqa:WPS219
|
||||
return self.orders[0].pickup_address.city.map
|
||||
|
||||
def draw( # noqa:C901,WPS210
|
||||
def draw( # noqa:C901
|
||||
self,
|
||||
restaurants: bool = True,
|
||||
order_counts: bool = False, # pragma: no cover
|
||||
|
|
@ -72,7 +72,7 @@ class Customer(meta.Base):
|
|||
db.Address.id.in_(
|
||||
row.primary_id
|
||||
for row in (
|
||||
db.session.query(db.Address.primary_id) # noqa:WPS221
|
||||
db.session.query(db.Address.primary_id)
|
||||
.join(db.Order, db.Address.id == db.Order.delivery_address_id)
|
||||
.filter(db.Order.customer_id == self.id)
|
||||
.distinct()
|
||||
|
|
@ -122,7 +122,7 @@ class Customer(meta.Base):
|
|||
db.session.query(db.Address)
|
||||
.filter(
|
||||
db.Address.id.in_(
|
||||
db.session.query(db.Address.primary_id) # noqa:WPS221
|
||||
db.session.query(db.Address.primary_id)
|
||||
.join(db.Order, db.Address.id == db.Order.pickup_address_id)
|
||||
.filter(db.Order.customer_id == self.id)
|
||||
.distinct()
|
||||
|
|
@ -132,14 +132,14 @@ class Customer(meta.Base):
|
|||
.all()
|
||||
)
|
||||
|
||||
for address in pickup_addresses: # noqa:WPS440
|
||||
for address in pickup_addresses:
|
||||
# Show the restaurant's name if there is only one.
|
||||
# Otherwise, list all the restaurants' ID's.
|
||||
# We cannot show the `Order.restaurant.name` due to the aggregation.
|
||||
restaurants = (
|
||||
db.session.query(db.Restaurant)
|
||||
.join(db.Address, db.Restaurant.address_id == db.Address.id)
|
||||
.filter(db.Address.primary_id == address.id) # noqa:WPS441
|
||||
.filter(db.Address.primary_id == address.id)
|
||||
.all()
|
||||
)
|
||||
if len(restaurants) == 1: # type:ignore
|
||||
|
|
@ -147,7 +147,7 @@ class Customer(meta.Base):
|
|||
f'{restaurants[0].name} (#{restaurants[0].id})' # type:ignore
|
||||
)
|
||||
else:
|
||||
tooltip = 'Restaurants ' + ', '.join( # noqa:WPS336
|
||||
tooltip = 'Restaurants ' + ', '.join(
|
||||
f'#{restaurant.id}' for restaurant in restaurants # type:ignore
|
||||
)
|
||||
|
||||
|
|
@ -156,7 +156,7 @@ class Customer(meta.Base):
|
|||
db.session.query(db.Order)
|
||||
.join(db.Address, db.Order.pickup_address_id == db.Address.id)
|
||||
.filter(db.Order.customer_id == self.id)
|
||||
.filter(db.Address.primary_id == address.id) # noqa:WPS441
|
||||
.filter(db.Address.primary_id == address.id)
|
||||
.count()
|
||||
)
|
||||
if n_orders >= 25:
|
||||
|
|
@ -170,9 +170,9 @@ class Customer(meta.Base):
|
|||
else:
|
||||
radius = 1
|
||||
|
||||
tooltip += f' | n_orders={n_orders}' # noqa:WPS336
|
||||
tooltip += f' | n_orders={n_orders}'
|
||||
|
||||
address.draw( # noqa:WPS441
|
||||
address.draw(
|
||||
radius=radius,
|
||||
color=config.RESTAURANT_COLOR,
|
||||
fill_color=config.RESTAURANT_COLOR,
|
||||
|
|
@ -181,7 +181,7 @@ class Customer(meta.Base):
|
|||
)
|
||||
|
||||
else:
|
||||
address.draw( # noqa:WPS441
|
||||
address.draw(
|
||||
radius=1,
|
||||
color=config.RESTAURANT_COLOR,
|
||||
tooltip=tooltip,
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ class Forecast(meta.Base):
|
|||
__tablename__ = 'forecasts'
|
||||
|
||||
# Columns
|
||||
id = sa.Column(sa.Integer, primary_key=True, autoincrement=True) # noqa:WPS125
|
||||
id = sa.Column(sa.Integer, primary_key=True, autoincrement=True)
|
||||
pixel_id = sa.Column(sa.Integer, nullable=False, index=True)
|
||||
start_at = sa.Column(sa.DateTime, nullable=False)
|
||||
time_step = sa.Column(sa.SmallInteger, nullable=False)
|
||||
|
|
@ -151,7 +151,7 @@ class Forecast(meta.Base):
|
|||
)
|
||||
|
||||
@classmethod
|
||||
def from_dataframe( # noqa:WPS210,WPS211
|
||||
def from_dataframe(
|
||||
cls,
|
||||
pixel: db.Pixel,
|
||||
time_step: int,
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ class Grid(meta.Base):
|
|||
__tablename__ = 'grids'
|
||||
|
||||
# Columns
|
||||
id = sa.Column( # noqa:WPS125
|
||||
id = sa.Column(
|
||||
sa.SmallInteger,
|
||||
primary_key=True,
|
||||
autoincrement=True,
|
||||
|
|
@ -63,7 +63,7 @@ class Grid(meta.Base):
|
|||
return round((self.side_length**2) / 1_000_000, 1)
|
||||
|
||||
@classmethod
|
||||
def gridify(cls, city: db.City, side_length: int) -> db.Grid: # noqa:WPS210
|
||||
def gridify(cls, city: db.City, side_length: int) -> db.Grid:
|
||||
"""Create a fully populated `Grid` for a `city`.
|
||||
|
||||
The `Grid` contains only `Pixel`s that have at least one
|
||||
|
|
@ -124,7 +124,7 @@ class Grid(meta.Base):
|
|||
return self
|
||||
|
||||
@property # pragma: no cover
|
||||
def map(self) -> folium.Map: # noqa:WPS125
|
||||
def map(self) -> folium.Map:
|
||||
"""Shortcut to the `.city.map` object."""
|
||||
return self.city.map
|
||||
|
||||
|
|
|
|||
|
|
@ -12,11 +12,11 @@ Base: Any = orm.declarative_base(
|
|||
metadata=sa.MetaData(
|
||||
schema=velofy.config.CLEAN_SCHEMA,
|
||||
naming_convention={
|
||||
'pk': 'pk_%(table_name)s', # noqa:WPS323
|
||||
'fk': 'fk_%(table_name)s_to_%(referred_table_name)s_via_%(column_0_N_name)s', # noqa:E501,WPS323
|
||||
'uq': 'uq_%(table_name)s_on_%(column_0_N_name)s', # noqa:WPS323
|
||||
'ix': 'ix_%(table_name)s_on_%(column_0_N_name)s', # noqa:WPS323
|
||||
'ck': 'ck_%(table_name)s_on_%(constraint_name)s', # noqa:WPS323
|
||||
'pk': 'pk_%(table_name)s',
|
||||
'fk': 'fk_%(table_name)s_to_%(referred_table_name)s_via_%(column_0_N_name)s', # noqa:E501
|
||||
'uq': 'uq_%(table_name)s_on_%(column_0_N_name)s',
|
||||
'ix': 'ix_%(table_name)s_on_%(column_0_N_name)s',
|
||||
'ck': 'ck_%(table_name)s_on_%(constraint_name)s',
|
||||
},
|
||||
),
|
||||
)
|
||||
|
|
|
|||
|
|
@ -12,13 +12,13 @@ from velofy import db
|
|||
from velofy.db import meta
|
||||
|
||||
|
||||
class Order(meta.Base): # noqa:WPS214
|
||||
class Order(meta.Base):
|
||||
"""An order by a `Customer` of the UDP."""
|
||||
|
||||
__tablename__ = 'orders'
|
||||
|
||||
# Generic columns
|
||||
id = sa.Column(sa.Integer, primary_key=True, autoincrement=False) # noqa:WPS125
|
||||
id = sa.Column(sa.Integer, primary_key=True, autoincrement=False)
|
||||
_delivery_id = sa.Column('delivery_id', sa.Integer, index=True, unique=True)
|
||||
customer_id = sa.Column(sa.Integer, nullable=False, index=True)
|
||||
placed_at = sa.Column(sa.DateTime, nullable=False, index=True)
|
||||
|
|
@ -364,7 +364,7 @@ class Order(meta.Base): # noqa:WPS214
|
|||
def corrected(self) -> bool:
|
||||
"""If any timestamp was corrected as compared to the original data."""
|
||||
return (
|
||||
self.scheduled_delivery_at_corrected # noqa:WPS222 => too much logic
|
||||
self.scheduled_delivery_at_corrected # => too much logic
|
||||
or self.cancelled_at_corrected
|
||||
or self.restaurant_notified_at_corrected
|
||||
or self.restaurant_confirmed_at_corrected
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ class Pixel(meta.Base):
|
|||
__tablename__ = 'pixels'
|
||||
|
||||
# Columns
|
||||
id = sa.Column(sa.Integer, primary_key=True, autoincrement=True) # noqa:WPS125
|
||||
id = sa.Column(sa.Integer, primary_key=True, autoincrement=True)
|
||||
grid_id = sa.Column(sa.SmallInteger, nullable=False, index=True)
|
||||
n_x = sa.Column(sa.SmallInteger, nullable=False, index=True)
|
||||
n_y = sa.Column(sa.SmallInteger, nullable=False, index=True)
|
||||
|
|
@ -141,11 +141,11 @@ class Pixel(meta.Base):
|
|||
return self
|
||||
|
||||
@property # pragma: no cover
|
||||
def map(self) -> folium.Map: # noqa:WPS125
|
||||
def map(self) -> folium.Map:
|
||||
"""Shortcut to the `.city.map` object."""
|
||||
return self.grid.city.map
|
||||
|
||||
def draw( # noqa:C901,WPS210
|
||||
def draw( # noqa:C901
|
||||
self,
|
||||
restaurants: bool = True,
|
||||
order_counts: bool = False, # pragma: no cover
|
||||
|
|
@ -223,7 +223,7 @@ class Pixel(meta.Base):
|
|||
f'{restaurants[0].name} (#{restaurants[0].id})' # type:ignore
|
||||
)
|
||||
else:
|
||||
tooltip = 'Restaurants ' + ', '.join( # noqa:WPS336
|
||||
tooltip = 'Restaurants ' + ', '.join(
|
||||
f'#{restaurant.id}' for restaurant in restaurants # type:ignore
|
||||
)
|
||||
|
||||
|
|
@ -247,7 +247,7 @@ class Pixel(meta.Base):
|
|||
else:
|
||||
radius = 1
|
||||
|
||||
tooltip += f' | n_orders={n_orders}' # noqa:WPS336
|
||||
tooltip += f' | n_orders={n_orders}'
|
||||
|
||||
address.draw(
|
||||
radius=radius,
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ class ReplaySimulation(meta.Base):
|
|||
__tablename__ = 'replay_simulations'
|
||||
|
||||
# Columns
|
||||
id = sa.Column(sa.Integer, primary_key=True, autoincrement=True) # noqa:WPS125
|
||||
id = sa.Column(sa.Integer, primary_key=True, autoincrement=True)
|
||||
city_id = sa.Column(sa.SmallInteger, nullable=False, index=True)
|
||||
strategy = sa.Column(sa.Unicode(length=100), nullable=False, index=True)
|
||||
# `.run` may be used as random seed.
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ class Restaurant(meta.Base):
|
|||
__tablename__ = 'restaurants'
|
||||
|
||||
# Columns
|
||||
id = sa.Column( # noqa:WPS125
|
||||
id = sa.Column(
|
||||
sa.SmallInteger,
|
||||
primary_key=True,
|
||||
autoincrement=False,
|
||||
|
|
@ -70,7 +70,7 @@ class Restaurant(meta.Base):
|
|||
return self
|
||||
|
||||
@property # pragma: no cover
|
||||
def map(self) -> folium.Map: # noqa:WPS125
|
||||
def map(self) -> folium.Map:
|
||||
"""Shortcut to the `.address.city.map` object."""
|
||||
return self.address.city.map
|
||||
|
||||
|
|
@ -100,7 +100,7 @@ class Restaurant(meta.Base):
|
|||
db.Address.id.in_(
|
||||
row.primary_id
|
||||
for row in (
|
||||
db.session.query(db.Address.primary_id) # noqa:WPS221
|
||||
db.session.query(db.Address.primary_id)
|
||||
.join(
|
||||
db.Order,
|
||||
db.Address.id == db.Order.delivery_address_id,
|
||||
|
|
|
|||
|
|
@ -69,4 +69,4 @@ def rgb_to_hex(*args: float) -> str: # pragma: no cover
|
|||
int(255 * args[1]),
|
||||
int(255 * args[2]),
|
||||
)
|
||||
return f'#{red:02x}{green:02x}{blue:02x}' # noqa:WPS221
|
||||
return f'#{red:02x}{green:02x}{blue:02x}'
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ from typing import Optional, Tuple
|
|||
import utm
|
||||
|
||||
|
||||
class Location: # noqa:WPS214
|
||||
class Location:
|
||||
"""A location represented in WGS84 and UTM coordinates.
|
||||
|
||||
WGS84:
|
||||
|
|
@ -50,7 +50,7 @@ class Location: # noqa:WPS214
|
|||
>>> Location(43.6532, -79.3832)
|
||||
<Location: 17T 630378 4834625>
|
||||
"""
|
||||
return f'<Location: {self.zone} {self.easting} {self.northing}>' # noqa:WPS221
|
||||
return f'<Location: {self.zone} {self.easting} {self.northing}>'
|
||||
|
||||
@property
|
||||
def latitude(self) -> float:
|
||||
|
|
@ -104,7 +104,7 @@ class Location: # noqa:WPS214
|
|||
return (self.easting, self.northing) == (other.easting, other.northing)
|
||||
|
||||
@property
|
||||
def x(self) -> int: # noqa:WPS111
|
||||
def x(self) -> int:
|
||||
"""The `.easting` of the location in meters, relative to some origin.
|
||||
|
||||
The origin, which defines the `(0, 0)` coordinate, is set with `.relate_to()`.
|
||||
|
|
@ -115,7 +115,7 @@ class Location: # noqa:WPS214
|
|||
return self._normalized_easting
|
||||
|
||||
@property
|
||||
def y(self) -> int: # noqa:WPS111
|
||||
def y(self) -> int:
|
||||
"""The `.northing` of the location in meters, relative to some origin.
|
||||
|
||||
The origin, which defines the `(0, 0)` coordinate, is set with `.relate_to()`.
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ def predict(
|
|||
"""
|
||||
# Initialize R only if it is actually used.
|
||||
# For example, the nox session "ci-tests-fast" does not use it.
|
||||
from velofy import init_r # noqa:F401,WPS433
|
||||
from velofy import init_r # noqa:F401
|
||||
|
||||
# Re-seed R every time it is used to ensure reproducibility.
|
||||
robjects.r('set.seed(42)')
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ from rpy2 import robjects
|
|||
from rpy2.robjects import pandas2ri
|
||||
|
||||
|
||||
def stl( # noqa:C901,WPS210,WPS211
|
||||
def stl( # noqa:C901
|
||||
time_series: pd.Series,
|
||||
*,
|
||||
frequency: int,
|
||||
|
|
@ -26,7 +26,7 @@ def stl( # noqa:C901,WPS210,WPS211
|
|||
jt: Optional[int] = None,
|
||||
jl: Optional[int] = None,
|
||||
ni: int = 2,
|
||||
no: int = 0, # noqa:WPS110
|
||||
no: int = 0,
|
||||
) -> pd.DataFrame:
|
||||
"""Decompose a time series into seasonal, trend, and residual components.
|
||||
|
||||
|
|
@ -157,7 +157,7 @@ def stl( # noqa:C901,WPS210,WPS211
|
|||
|
||||
# Initialize R only if it is actually used.
|
||||
# For example, the nox session "ci-tests-fast" does not use it.
|
||||
from velofy import init_r # noqa:F401,WPS433
|
||||
from velofy import init_r # noqa:F401
|
||||
|
||||
# Re-seed R every time it is used to ensure reproducibility.
|
||||
robjects.r('set.seed(42)')
|
||||
|
|
@ -177,7 +177,7 @@ def stl( # noqa:C901,WPS210,WPS211
|
|||
jl,
|
||||
robust,
|
||||
ni,
|
||||
no, # noqa:WPS221
|
||||
no,
|
||||
)
|
||||
|
||||
# Unpack the result to a `pd.DataFrame`.
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ def predict(
|
|||
"""
|
||||
# Initialize R only if it is actually used.
|
||||
# For example, the nox session "ci-tests-fast" does not use it.
|
||||
from velofy import init_r # noqa:F401,WPS433
|
||||
from velofy import init_r # noqa:F401
|
||||
|
||||
# Re-seed R every time it is used to ensure reproducibility.
|
||||
robjects.r('set.seed(42)')
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue