diff --git a/src/velofy/configuration.py b/src/velofy/configuration.py index 8840921..3ac9caf 100644 --- a/src/velofy/configuration.py +++ b/src/velofy/configuration.py @@ -1,6 +1,6 @@ """Provide package-wide configuration. -This module provides utils to create new `Config` objects +This module provides utils to create new `Config`s on the fly, mainly for testing and migrating. Within this package, use the `config` proxy at the package's top level @@ -98,7 +98,7 @@ class TestingConfig(Config): def make_config(env: str = "production") -> Config: - """Create a new `Config` object. + """Create a new `Config`. Args: env: either "production" or "testing" diff --git a/src/velofy/db/addresses.py b/src/velofy/db/addresses.py index adbef87..d3bb61f 100644 --- a/src/velofy/db/addresses.py +++ b/src/velofy/db/addresses.py @@ -151,7 +151,7 @@ class Address(meta.Base): def location(self) -> utils.Location: """The location of the address. - The returned `Location` object relates to `.city.southwest`. + The returned `Location` relates to `.city.southwest`. `.x` and `.y` are aliases of `.location.x` and `.location.y`. diff --git a/src/velofy/db/addresses_addresses.py b/src/velofy/db/addresses_addresses.py index aa4b38b..87efe59 100644 --- a/src/velofy/db/addresses_addresses.py +++ b/src/velofy/db/addresses_addresses.py @@ -1,4 +1,4 @@ -"""Model for the `Path` relationship between two `Address` objects.""" +"""Model for the `Path` relationship between two `Address`es.""" import functools import itertools @@ -19,9 +19,9 @@ from velofy.db import utils class Path(meta.Base): - """Path between two `Address` objects. + """Path between two `Address`es. - Models the path between two `Address` objects, including directions + Models the path between two `Address`es, including directions for a `Courier` to get from one `Address` to another. As the couriers are on bicycles, we model the paths as @@ -74,7 +74,7 @@ class Path(meta.Base): # All foreign keys `RESTRICT` # because data of finished stages must never change through cascades # - # The two `Address` objects must be in the same `.city` + # The two `Address`es must be in the same `.city` sa.ForeignKeyConstraint( ["first_address_id", "city_id"], ["addresses.id", "addresses.city_id"], @@ -128,16 +128,16 @@ class Path(meta.Base): *addresses: db.Address, google_maps: bool = False, ) -> list[t.Self]: - """Calculate pair-wise paths for `Address` objects. + """Calculate pair-wise paths for `Address`es. This is the main constructor method for the class. - It handles the "sorting" of the `Address` objects by `.id`, which is + It handles the "sorting" of the `Address`es by `.id`, which is the logic that enforces the symmetric graph behind the paths. Args: *addresses: to calculate the pair-wise paths for; - must contain at least two `Address` objects + must contain at least two `Address`es google_maps: if `.bicycle_distance` and `._directions` should be populated with a query to the Google Maps Directions API; by default, only the `.air_distance` is calculated with `geopy` @@ -152,7 +152,7 @@ class Path(meta.Base): # ... which a precedence constraint for the `.id`s enforces first, second = sorted(pair, key=lambda address: address.id) - # If there is no `Path` object in the database ... + # If there is no `Path` in the database ... path = db.session.scalars( sa.select(cls) .where(cls.first_address == first) @@ -184,7 +184,7 @@ class Path(meta.Base): @classmethod def from_order(cls, order: db.Order, *, google_maps: bool = False) -> t.Self: - """Calculate the path for an `Order` object. + """Calculate the path for an `Order`. The path goes from the `Order.pickup_address` to the `Order.delivery_address`. diff --git a/src/velofy/db/addresses_pixels.py b/src/velofy/db/addresses_pixels.py index 443e044..2a07ef2 100644 --- a/src/velofy/db/addresses_pixels.py +++ b/src/velofy/db/addresses_pixels.py @@ -1,4 +1,4 @@ -"""Model for the many-to-many relationship between `Address` and `Pixel` objects.""" +"""Model for the many-to-many relationship between `Address` and `Pixel`s.""" import sqlalchemy as sa from sqlalchemy import orm diff --git a/src/velofy/db/cities.py b/src/velofy/db/cities.py index c72222f..58b1f5a 100644 --- a/src/velofy/db/cities.py +++ b/src/velofy/db/cities.py @@ -135,7 +135,7 @@ class City(meta.Base): @functools.cached_property # pragma: no cover def map(self) -> folium.Map: - """A `folium.Map` object aligned with the city's viewport. + """A `folium.Map` aligned with the city's viewport. The map is mutable and changed from various locations in the code base. Use `.clear_map()` to start over with an empty map. diff --git a/src/velofy/db/connection.py b/src/velofy/db/connection.py index 6808ff7..e9db3ba 100644 --- a/src/velofy/db/connection.py +++ b/src/velofy/db/connection.py @@ -1,6 +1,6 @@ """Provide connection utils for the ORM layer. -The `session` object is used as a global within the `velofy` package, +The `session` is used as a global within the `velofy` package, like `db.session` in Flask-SQLAlchemy: It is a proxy to one session per thread. The engine and the session are created only on first use. So, importing the package does not require a database. diff --git a/src/velofy/db/forecasts.py b/src/velofy/db/forecasts.py index 4b1d733..1ee9801 100644 --- a/src/velofy/db/forecasts.py +++ b/src/velofy/db/forecasts.py @@ -197,12 +197,12 @@ class Forecast(meta.Base): model: str, data: pd.DataFrame, ) -> list[t.Self]: - """Convert results from the forecasting `*Model`s into `Forecast` objects. + """Convert results from the forecasting `*Model`s into `Forecast`s. This is an alternative constructor method. Background: The functions in `velofy.forecasts.methods` - return `pd.Dataframe`s with "start_at" (i.e., `pd.Timestamp` objects) + return `pd.Dataframe`s with "start_at" (i.e., `pd.Timestamp`s) values in the index and five columns "prediction", "low80", "high80", "low95", and "high95" with `np.float` values. The `*Model.predict()` methods in `velofy.forecasts.models` then add an "actual" @@ -219,7 +219,7 @@ class Forecast(meta.Base): with the six columns holding `float`s) Returns: - forecasts: the `data` as `Forecast` objects + forecasts: the `data` as `Forecast`s """ forecasts = [] diff --git a/src/velofy/db/grids.py b/src/velofy/db/grids.py index 71bafbf..3633341 100644 --- a/src/velofy/db/grids.py +++ b/src/velofy/db/grids.py @@ -75,7 +75,7 @@ class Grid(meta.Base): """Create a fully populated `Grid` for a `city`. The `Grid` contains only `Pixel`s that have at least one - `Order.pickup_address`. `Address` objects outside the `.city`'s + `Order.pickup_address`. `Address`es outside the `.city`'s viewport are discarded. Args: @@ -117,7 +117,7 @@ class Grid(meta.Base): # Determine which `pixel` the `address` belongs to ... n_x, n_y = address.x // side_length, address.y // side_length - # ... and create a new `Pixel` object if necessary + # ... and create a new `Pixel` if necessary if (n_x, n_y) not in pixels: pixels[(n_x, n_y)] = db.Pixel(n_x=n_x, n_y=n_y) grid.pixels.append(pixels[(n_x, n_y)]) diff --git a/src/velofy/db/pixels.py b/src/velofy/db/pixels.py index 1d43308..7d709d3 100644 --- a/src/velofy/db/pixels.py +++ b/src/velofy/db/pixels.py @@ -17,7 +17,7 @@ from velofy.db import utils class Pixel(meta.Base): """A pixel in a `Grid`. - Square pixels aggregate `Address` objects within a `City`. + Square pixels aggregate `Address`es within a `City`. Every `Address` belongs to exactly one `Pixel` in a `Grid`. Every `Pixel` has a unique `n_x`-`n_y` coordinate within the `Grid`. diff --git a/src/velofy/forecasts/__init__.py b/src/velofy/forecasts/__init__.py index bf5b5c5..95553ae 100644 --- a/src/velofy/forecasts/__init__.py +++ b/src/velofy/forecasts/__init__.py @@ -3,7 +3,7 @@ This sub-package is divided into further sub-packages and modules as follows: `methods` contains various time series related statistical methods, implemented -as plain `function` objects that are used to predict into the future given a +as plain `function`s that are used to predict into the future given a time series of historic order counts. The methods are context-agnostic, meaning that they only take and return `pd.Series/DataFrame`s holding numbers and are not concerned with how these numbers were generated or what they mean. @@ -12,7 +12,7 @@ in R using the `rpy2` library. Others, like `extrapolate_season.predict()`, are written in plain Python. `timify` defines an `OrderHistory` class that abstracts away the communication -with the database and provides `pd.Series` objects with the order counts that +with the database and provides `pd.Series` with the order counts that are fed into the `methods`. In particular, it uses SQL statements behind the scenes to calculate the historic order counts on a per-`Pixel` level. Once the data is loaded from the database, an `OrderHistory` instance provides various diff --git a/src/velofy/forecasts/models/__init__.py b/src/velofy/forecasts/models/__init__.py index 80c8c12..3c41141 100644 --- a/src/velofy/forecasts/models/__init__.py +++ b/src/velofy/forecasts/models/__init__.py @@ -17,7 +17,7 @@ This sub-package is organized as follows. The `base` module defines an abstract `ForecastingModelABC` class that unifies how the concrete `*Model`s work. While the abstract `.predict()` method returns a `pd.DataFrame` (= basically, the result of one of the forecasting `methods`, the concrete `.make_forecast()` -method converts the results into `Forecast` (=ORM) objects. +method converts the results into `Forecast`s, the ORM model. Also, `.make_forecast()` implements a caching strategy where already made `Forecast`s are loaded from the database instead of calculating them again, which could be a heavier computation. diff --git a/src/velofy/forecasts/models/base.py b/src/velofy/forecasts/models/base.py index b4ea0f7..a9ca1e4 100644 --- a/src/velofy/forecasts/models/base.py +++ b/src/velofy/forecasts/models/base.py @@ -109,7 +109,7 @@ class ForecastingModelABC(abc.ABC): db.session.add_all(forecasts) db.session.commit() - # The one `Forecast` object asked for must be in `forecasts` + # The one `Forecast` asked for must be in `forecasts` # if the concrete `*Model.predict()` method works correctly; ... for forecast in forecasts: if forecast.start_at == predict_at: diff --git a/src/velofy/forecasts/timify.py b/src/velofy/forecasts/timify.py index b5ff6fc..2d16cb2 100644 --- a/src/velofy/forecasts/timify.py +++ b/src/velofy/forecasts/timify.py @@ -19,7 +19,7 @@ class OrderHistory: """ def __init__(self, grid: db.Grid, time_step: int) -> None: - """Initialize a new `OrderHistory` object. + """Initialize a new `OrderHistory`. Args: grid: pixel grid used to aggregate orders spatially @@ -52,7 +52,8 @@ class OrderHistory: def totals(self) -> pd.DataFrame: """The order totals by `Pixel` and `.time_step`. - The returned object should not be mutated! + The returned `DataFrame` is the cached data itself. + So, it must not be mutated! Returns: order_totals: a one-column `DataFrame` with a `MultiIndex` of the diff --git a/tests/config.py b/tests/config.py index 304ced3..9d1fbe9 100644 --- a/tests/config.py +++ b/tests/config.py @@ -19,7 +19,7 @@ START = dt.datetime(YEAR, MONTH, DAY, pkg_config.SERVICE_START, 0) _end = START + dt.timedelta(days=56) # `56` as `START` is not included END = dt.datetime(_end.year, _end.month, _end.day, pkg_config.SERVICE_END, 0) -# Default time steps (in minutes), for example, for `OrderHistory` objects +# Default time steps (in minutes), for example, for `OrderHistory`s LONG_TIME_STEP = 60 SHORT_TIME_STEP = 30 TIME_STEPS = (SHORT_TIME_STEP, LONG_TIME_STEP) diff --git a/tests/conftest.py b/tests/conftest.py index 30740d4..d3727ee 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -102,7 +102,7 @@ def db_session(db_connection, monkeypatch): # => Commits inside a test case only release a savepoint session = orm.Session(bind=db_connection, join_transaction_mode="create_savepoint") - # Monkey patch the package's global `session` object, + # Monkey patch the package's global `session`, # which is used heavily in the code base monkeypatch.setattr(db, "session", session) diff --git a/tests/console/test_gridify.py b/tests/console/test_gridify.py index 75b3d69..f145efb 100644 --- a/tests/console/test_gridify.py +++ b/tests/console/test_gridify.py @@ -18,7 +18,7 @@ def test_two_pixels_with_two_addresses( make_restaurant, make_order, ): - """Two `Address` objects in distinct `Pixel` objects. + """Two `Address`es in distinct `Pixel`s. This is roughly the same test case as `tests.db.test_grids.test_two_pixels_with_two_addresses`. diff --git a/tests/db/fake_data/factories/orders/ad_hoc.py b/tests/db/fake_data/factories/orders/ad_hoc.py index b2af0a9..ee12488 100644 --- a/tests/db/fake_data/factories/orders/ad_hoc.py +++ b/tests/db/fake_data/factories/orders/ad_hoc.py @@ -31,7 +31,7 @@ class AdHocOrderFactory(alchemy.SQLAlchemyModelFactory): class Params: """Define flags that overwrite some attributes. - The `factory.Trait` objects in this class are executed after all + The `factory.Trait`s in this class are executed after all the normal attributes in the `OrderFactory` classes were evaluated. Flags: diff --git a/tests/db/fake_data/factories/orders/scheduled.py b/tests/db/fake_data/factories/orders/scheduled.py index 7d4003f..a52c9c8 100644 --- a/tests/db/fake_data/factories/orders/scheduled.py +++ b/tests/db/fake_data/factories/orders/scheduled.py @@ -23,7 +23,7 @@ class ScheduledOrderFactory(ad_hoc.AdHocOrderFactory): # Attributes regarding the specialization of an `Order`: ad-hoc or scheduled placed_at = factory.LazyFunction(utils.early_in_the_morning) ad_hoc = False - # Discrete `datetime` objects in the "core" lunch time are enough + # Discrete `datetime`s in the "core" lunch time are enough scheduled_delivery_at = factory.LazyFunction( lambda: random.choice( [ diff --git a/tests/db/fake_data/factories/utils.py b/tests/db/fake_data/factories/utils.py index 9eb1f41..7bee014 100644 --- a/tests/db/fake_data/factories/utils.py +++ b/tests/db/fake_data/factories/utils.py @@ -15,7 +15,7 @@ def random_timespan( max_minutes=0, max_seconds=0, ): - """A randomized `timedelta` object between the specified arguments.""" + """A randomized `timedelta` between the specified arguments.""" total_min_seconds = min_hours * 3600 + min_minutes * 60 + min_seconds total_max_seconds = max_hours * 3600 + max_minutes * 60 + max_seconds return dt.timedelta( @@ -27,6 +27,6 @@ def random_timespan( def early_in_the_morning(): - """A randomized `datetime` object early in the morning.""" + """A randomized `datetime` early in the morning.""" early = dt.datetime(*test_config.DATE, 3, 0) return early + random_timespan(max_hours=2) diff --git a/tests/db/fake_data/fixture_makers.py b/tests/db/fake_data/fixture_makers.py index 268dc5f..e71e1ac 100644 --- a/tests/db/fake_data/fixture_makers.py +++ b/tests/db/fake_data/fixture_makers.py @@ -12,7 +12,7 @@ def make_address(city): factories.AddressFactory.reset_sequence(1) def func(**kwargs): - """Create an `Address` object in the `city`.""" + """Create an `Address` in the `city`.""" address = factories.AddressFactory.build(**kwargs) city.addresses.append(address) @@ -29,7 +29,7 @@ def make_courier(): factories.CourierFactory.reset_sequence(1) def func(**kwargs): - """Create a new `Courier` object.""" + """Create a new `Courier`.""" return factories.CourierFactory.build(**kwargs) return func @@ -42,7 +42,7 @@ def make_customer(): factories.CustomerFactory.reset_sequence(1) def func(**kwargs): - """Create a new `Customer` object.""" + """Create a new `Customer`.""" return factories.CustomerFactory.build(**kwargs) return func @@ -55,7 +55,7 @@ def make_restaurant(make_address): factories.RestaurantFactory.reset_sequence(1) def func(address=None, **kwargs): - """Create a new `Restaurant` object. + """Create a new `Restaurant`. If no `address` is provided, a new `Address` is created. """ @@ -78,7 +78,7 @@ def make_order(make_address, make_courier, make_customer, make_restaurant): factories.AdHocOrderFactory.reset_sequence(1) def func(*, scheduled=False, restaurant=None, courier=None, **kwargs): - """Create a new `Order` object. + """Create a new `Order`. Each `Order` is made by a new `Customer` with a unique `Address` for delivery. @@ -123,7 +123,7 @@ def make_replay_order(make_order, simulation): factories.ReplayedOrderFactory.reset_sequence(1) def func(*, scheduled=False, order=None, **kwargs): - """Create a new `ReplayedOrder` object. + """Create a new `ReplayedOrder`. Each `ReplayOrder` is made by a new `Customer` with a unique `Address`. diff --git a/tests/db/fake_data/static_fixtures.py b/tests/db/fake_data/static_fixtures.py index 3923496..d4c534d 100644 --- a/tests/db/fake_data/static_fixtures.py +++ b/tests/db/fake_data/static_fixtures.py @@ -7,7 +7,7 @@ from velofy import db @pytest.fixture def city_data(): - """The data for the one and only `City` object as a `dict`.""" + """The data for the one and only `City` as a `dict`.""" return { "id": 1, "name": "Paris", @@ -24,49 +24,49 @@ def city_data(): @pytest.fixture def city(city_data): - """The one and only `City` object.""" + """The one and only `City`.""" return db.City(**city_data) @pytest.fixture def address(make_address): - """An `Address` object in the `city`.""" + """An `Address` in the `city`.""" return make_address() @pytest.fixture def courier(make_courier): - """A `Courier` object.""" + """A `Courier`.""" return make_courier() @pytest.fixture def customer(make_customer): - """A `Customer` object.""" + """A `Customer`.""" return make_customer() @pytest.fixture def restaurant(address, make_restaurant): - """A `Restaurant` object located at the `address`.""" + """A `Restaurant` located at the `address`.""" return make_restaurant(address=address) @pytest.fixture def order(make_order, restaurant): - """An ad-hoc `Order` object for the `restaurant`.""" + """An ad-hoc `Order` for the `restaurant`.""" return make_order(restaurant=restaurant) @pytest.fixture def pre_order(make_order, restaurant): - """A scheduled `Order` object for the `restaurant`.""" + """A scheduled `Order` for the `restaurant`.""" return make_order(restaurant=restaurant, scheduled=True) @pytest.fixture def replayed_order(make_replay_order, order): - """A `ReplayedOrder` object for the `restaurant`.""" + """A `ReplayedOrder` for the `restaurant`.""" return make_replay_order(order=order) @@ -84,7 +84,7 @@ def pixel(grid): @pytest.fixture def simulation_data(city): - """The data for the one and only `ReplaySimulation` object as a `dict`.""" + """The data for the one and only `ReplaySimulation` as a `dict`.""" return { "id": 1, "city": city, @@ -95,5 +95,5 @@ def simulation_data(city): @pytest.fixture def simulation(simulation_data): - """The one and only `ReplaySimulation` object.""" + """The one and only `ReplaySimulation`.""" return db.ReplaySimulation(**simulation_data) diff --git a/tests/db/replay/test_orders.py b/tests/db/replay/test_orders.py index 356cc66..e12506c 100644 --- a/tests/db/replay/test_orders.py +++ b/tests/db/replay/test_orders.py @@ -14,7 +14,7 @@ class TestSpecialMethods: """Test special methods in `ReplayedOrder`.""" def test_create_order(self, replayed_order): - """Test instantiation of a new `ReplayedOrder` object.""" + """Test instantiation of a new `ReplayedOrder`.""" assert replayed_order is not None def test_text_representation(self, replayed_order): diff --git a/tests/db/replay/test_simulations.py b/tests/db/replay/test_simulations.py index f03296f..e2e202f 100644 --- a/tests/db/replay/test_simulations.py +++ b/tests/db/replay/test_simulations.py @@ -5,7 +5,7 @@ class TestSpecialMethods: """Test special methods in `ReplaySimulation`.""" def test_create_simulation(self, simulation): - """Test instantiation of a new `ReplaySimulation` object.""" + """Test instantiation of a new `ReplaySimulation`.""" assert simulation is not None def test_text_representation(self, simulation): diff --git a/tests/db/test_addresses.py b/tests/db/test_addresses.py index 2d6af3d..239dd85 100644 --- a/tests/db/test_addresses.py +++ b/tests/db/test_addresses.py @@ -12,7 +12,7 @@ class TestSpecialMethods: """Test special methods in `Address`.""" def test_create_address(self, address): - """Test instantiation of a new `Address` object.""" + """Test instantiation of a new `Address`.""" assert address is not None def test_text_representation(self, address): diff --git a/tests/db/test_addresses_addresses.py b/tests/db/test_addresses_addresses.py index 81e774a..ae8b6bc 100644 --- a/tests/db/test_addresses_addresses.py +++ b/tests/db/test_addresses_addresses.py @@ -12,7 +12,7 @@ from velofy.db import utils @pytest.fixture def another_address(make_address): - """Another `Address` object in the `city`.""" + """Another `Address` in the `city`.""" return make_address() @@ -45,7 +45,7 @@ class TestSpecialMethods: """Test special methods in `Path`.""" def test_create_an_address_address_association(self, path): - """Test instantiation of a new `Path` object.""" + """Test instantiation of a new `Path`.""" assert path is not None @@ -633,7 +633,7 @@ class TestSyncWithGoogleMaps: monkeypatch.setattr(gm.Client, "directions", directions) def test_sync_instances_with_google_maps(self, path): - """Call the method for a `Path` object without Google data.""" + """Call the method for a `Path` without Google data.""" path.bicycle_distance = None path.bicycle_duration = None path._directions = None @@ -645,7 +645,7 @@ class TestSyncWithGoogleMaps: assert path._directions is not None def test_repeated_sync_instances_with_google_maps(self, path): - """Call the method for a `Path` object with Google data. + """Call the method for a `Path` with Google data. That call should immediately return without changing any data. diff --git a/tests/db/test_addresses_pixels.py b/tests/db/test_addresses_pixels.py index 03af57d..45e2cb5 100644 --- a/tests/db/test_addresses_pixels.py +++ b/tests/db/test_addresses_pixels.py @@ -27,7 +27,7 @@ class TestSpecialMethods: """Test special methods in `AddressPixelAssociation`.""" def test_create_an_address_pixel_association(self, assoc): - """Test instantiation of a new `AddressPixelAssociation` object.""" + """Test instantiation of a new `AddressPixelAssociation`.""" assert assoc is not None diff --git a/tests/db/test_cities.py b/tests/db/test_cities.py index cc7df6a..4bd9b8e 100644 --- a/tests/db/test_cities.py +++ b/tests/db/test_cities.py @@ -11,7 +11,7 @@ class TestSpecialMethods: """Test special methods in `City`.""" def test_create_city(self, city): - """Test instantiation of a new `City` object.""" + """Test instantiation of a new `City`.""" assert city is not None def test_text_representation(self, city): diff --git a/tests/db/test_couriers.py b/tests/db/test_couriers.py index d66a5fe..8bb0868 100644 --- a/tests/db/test_couriers.py +++ b/tests/db/test_couriers.py @@ -11,7 +11,7 @@ class TestSpecialMethods: """Test special methods in `Courier`.""" def test_create_courier(self, courier): - """Test instantiation of a new `Courier` object.""" + """Test instantiation of a new `Courier`.""" assert courier is not None def test_text_representation(self, courier): diff --git a/tests/db/test_customer.py b/tests/db/test_customer.py index ec2ba2c..8a088c9 100644 --- a/tests/db/test_customer.py +++ b/tests/db/test_customer.py @@ -10,7 +10,7 @@ class TestSpecialMethods: """Test special methods in `Customer`.""" def test_create_customer(self, customer): - """Test instantiation of a new `Customer` object.""" + """Test instantiation of a new `Customer`.""" assert customer is not None def test_text_representation(self, customer): diff --git a/tests/db/test_forecasts.py b/tests/db/test_forecasts.py index bb9fc2d..2065a16 100644 --- a/tests/db/test_forecasts.py +++ b/tests/db/test_forecasts.py @@ -43,7 +43,7 @@ class TestSpecialMethods: """Test special methods in `Forecast`.""" def test_create_forecast(self, forecast): - """Test instantiation of a new `Forecast` object.""" + """Test instantiation of a new `Forecast`.""" assert forecast is not None def test_text_representation(self, forecast): diff --git a/tests/db/test_grids.py b/tests/db/test_grids.py index 9ff73fd..b074705 100644 --- a/tests/db/test_grids.py +++ b/tests/db/test_grids.py @@ -11,7 +11,7 @@ class TestSpecialMethods: """Test special methods in `Grid`.""" def test_create_grid(self, grid): - """Test instantiation of a new `Grid` object.""" + """Test instantiation of a new `Grid`.""" assert grid is not None def test_text_representation(self, grid): @@ -109,7 +109,7 @@ class TestGridification: @pytest.mark.no_cover def test_no_pixel_without_addresses(self, city, addresses_mock): - """Without orders, there are no `Pixel` objects on the `grid`. + """Without orders, there are no `Pixel`s on the `grid`. This test case skips the `for`-loop inside `Grid.gridify()`. """ @@ -147,7 +147,7 @@ class TestGridification: horizontal and vertical distances of the viewport. This test case is necessary as `test_one_pixel_with_one_address` - does not have to re-use an already created `Pixel` object internally. + does not have to re-use an already created `Pixel` internally. """ orders = [make_order(), make_order()] addresses_mock.return_value = [order.pickup_address for order in orders] @@ -195,11 +195,11 @@ class TestGridification: @pytest.mark.no_cover def test_two_pixels_with_two_addresses(self, city, make_address, addresses_mock): - """Two `Address` objects in distinct `Pixel` objects. + """Two `Address`es in distinct `Pixel`s. This test is more of a sanity check. """ - # Create two `Address` objects in distinct `Pixel`s + # Create two `Address`es in distinct `Pixel`s addresses_mock.return_value = [ # One `Address` in the lower-left `Pixel`, ... make_address(latitude=48.8357377, longitude=2.2517412), @@ -232,12 +232,12 @@ class TestGridification: make_order, side_length, ): - """With 100 random `Address` objects, a grid must have ... + """With 100 random `Address`es, a grid must have ... - ... between 1 and a deterministic upper bound of `Pixel` objects. + ... between 1 and a deterministic upper bound of `Pixel`s. This test creates confidence that the created `Grid` - objects adhere to the database constraints. + adheres to the database constraints. """ addresses = [make_address() for _ in range(100)] restaurants = [make_restaurant(address=address) for address in addresses] diff --git a/tests/db/test_orders.py b/tests/db/test_orders.py index b5bd5c2..035bf38 100644 --- a/tests/db/test_orders.py +++ b/tests/db/test_orders.py @@ -15,7 +15,7 @@ class TestSpecialMethods: """Test special methods in `Order`.""" def test_create_order(self, order): - """Test instantiation of a new `Order` object.""" + """Test instantiation of a new `Order`.""" assert order is not None def test_text_representation(self, order): @@ -1152,10 +1152,10 @@ def test_make_random_orders( make_restaurant, make_order, ): - """Sanity check the all the `make_*` fixtures. + """Sanity check all the `make_*` fixtures. - Ensure that all generated `Address`, `Courier`, `Customer`, `Restaurant`, - and `Order` objects adhere to the database constraints. + Ensure that all generated `Address`es, `Courier`s, `Customer`s, `Restaurant`s, + and `Order`s adhere to the database constraints. """ # Generate a large number of `Order`s to obtain a large variance of data for _ in range(1_000): @@ -1182,7 +1182,7 @@ def test_make_random_orders( else: cancel_before_pickup, cancel_after_pickup = False, False - # Writing all generated objects to the database checks their integrity + # Writing all generated data to the database checks their integrity # => An `IntegrityError` here means the fake data are flawed order = make_order( scheduled=scheduled, diff --git a/tests/db/test_pixels.py b/tests/db/test_pixels.py index b8c7b06..fbf24ba 100644 --- a/tests/db/test_pixels.py +++ b/tests/db/test_pixels.py @@ -11,7 +11,7 @@ class TestSpecialMethods: """Test special methods in `Pixel`.""" def test_create_pixel(self, pixel): - """Test instantiation of a new `Pixel` object.""" + """Test instantiation of a new `Pixel`.""" assert pixel is not None def test_text_representation(self, pixel): diff --git a/tests/db/test_restaurants.py b/tests/db/test_restaurants.py index 6831e00..9ec7ea6 100644 --- a/tests/db/test_restaurants.py +++ b/tests/db/test_restaurants.py @@ -11,7 +11,7 @@ class TestSpecialMethods: """Test special methods in `Restaurant`.""" def test_create_restaurant(self, restaurant): - """Test instantiation of a new `Restaurant` object.""" + """Test instantiation of a new `Restaurant`.""" assert restaurant is not None def test_text_representation(self, restaurant): diff --git a/tests/db/utils/test_locations.py b/tests/db/utils/test_locations.py index 8fcf621..d633406 100644 --- a/tests/db/utils/test_locations.py +++ b/tests/db/utils/test_locations.py @@ -13,7 +13,7 @@ ZONE = "31U" @pytest.fixture def location(address): - """A `Location` object based off the `address` fixture.""" + """A `Location` based off the `address` fixture.""" obj = utils.Location(address.latitude, address.longitude) assert obj.zone == ZONE # sanity check @@ -23,7 +23,7 @@ def location(address): @pytest.fixture def faraway_location(): - """A `Location` object far away from the `location`.""" + """A `Location` far away from the `location`.""" obj = utils.Location(latitude=0, longitude=0) assert obj.zone != ZONE # sanity check @@ -33,7 +33,7 @@ def faraway_location(): @pytest.fixture def origin(city): - """A `Location` object based off the one and only `city`.""" + """A `Location` based off the one and only `city`.""" obj = city.southwest assert obj.zone == ZONE # sanity check @@ -45,7 +45,7 @@ class TestSpecialMethods: """Test special methods in `Location`.""" def test_create_utm_coordinates(self, location): - """Test instantiation of a new `Location` object.""" + """Test instantiation of a new `Location`.""" assert location is not None def test_text_representation(self, location): diff --git a/tests/forecasts/conftest.py b/tests/forecasts/conftest.py index 79c0136..6c3271d 100644 --- a/tests/forecasts/conftest.py +++ b/tests/forecasts/conftest.py @@ -129,7 +129,7 @@ def order_totals(good_pixel_id): @pytest.fixture def order_history(order_totals, grid): - """An `OrderHistory` object that does not need the database. + """An `OrderHistory` that does not need the database. Uses the LONG_TIME_STEP as the length of a time step. """ diff --git a/tests/forecasts/test_models.py b/tests/forecasts/test_models.py index 6d68e72..70abfac 100644 --- a/tests/forecasts/test_models.py +++ b/tests/forecasts/test_models.py @@ -35,7 +35,7 @@ class TestGenericForecastingModelProperties: """ def test_create_model(self, model_cls, order_history): - """Test instantiation of a new and concrete `*Model` object.""" + """Test instantiation of a new and concrete `*Model`.""" model = model_cls(order_history=order_history) assert model is not None @@ -147,7 +147,7 @@ class TestGenericForecastingModelProperties: pixel, predict_at, ): - """`*Model.make_forecast()` returns a `Forecast` object.""" + """`*Model.make_forecast()` returns a `Forecast`.""" model = model_cls(order_history=order_history) result = model.make_forecast( @@ -171,7 +171,7 @@ class TestGenericForecastingModelProperties: pixel, predict_at, ): - """`*Model.make_forecast()` caches the `Forecast` object.""" + """`*Model.make_forecast()` caches the `Forecast`.""" model = model_cls(order_history=order_history) assert ( diff --git a/tests/forecasts/timify/test_aggregate_orders.py b/tests/forecasts/timify/test_aggregate_orders.py index 9b17a99..3515684 100644 --- a/tests/forecasts/timify/test_aggregate_orders.py +++ b/tests/forecasts/timify/test_aggregate_orders.py @@ -309,7 +309,7 @@ class TestAggregateOrders: make_restaurant, addresses_mock, ): - """A persisted `Grid` with two `Pixel` objects.""" + """A persisted `Grid` with two `Pixel`s.""" # One `Address` in the lower-left `Pixel`, ... address1 = make_address(latitude=48.8357377, longitude=2.2517412) # ... and another one in the upper-right one diff --git a/tests/test_config.py b/tests/test_config.py index b4608f3..72d8ba7 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -12,7 +12,7 @@ envs = ["production", "testing"] @pytest.mark.parametrize("env", envs) def test_config_repr(env): - """Config objects have the text representation ''.""" + """`Config`s have the text representation "".""" config = configuration.make_config(env) assert str(config) == ""