From ac82f0911cf9918a142bea9135ccbf06deb5335d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Div=C3=AD?= <43449526+Diviloper@users.noreply.github.com> Date: Tue, 30 Jul 2024 20:04:56 +0200 Subject: [PATCH] Update version number and add Black lint (#65) * Update version number * Add black lint workflow * Format code with black --- .github/workflows/black.yml | 20 + docs/conf.py | 57 +-- pymeos/__init__.py | 2 +- pymeos/aggregators/aggregator.py | 4 +- pymeos/boxes/stbox.py | 128 +++--- pymeos/boxes/tbox.py | 8 +- pymeos/collections/base/set.py | 24 +- pymeos/collections/geo/geoset.py | 18 +- pymeos/collections/number/floatset.py | 6 +- pymeos/collections/number/floatspan.py | 9 +- pymeos/collections/number/floatspanset.py | 15 +- pymeos/collections/number/intset.py | 6 +- pymeos/collections/number/intspan.py | 9 +- pymeos/collections/number/intspanset.py | 13 +- pymeos/collections/text/textset.py | 6 +- pymeos/collections/time/dateset.py | 34 +- pymeos/collections/time/datespan.py | 23 +- pymeos/collections/time/datespanset.py | 20 +- pymeos/collections/time/tstzset.py | 29 +- pymeos/collections/time/tstzspan.py | 17 +- pymeos/collections/time/tstzspanset.py | 15 +- pymeos/main/tbool.py | 9 +- pymeos/main/tfloat.py | 12 +- pymeos/main/tint.py | 9 +- pymeos/main/tpoint.py | 40 +- pymeos/main/ttext.py | 9 +- pymeos/temporal/tsequence.py | 8 +- pymeos/temporal/tsequenceset.py | 8 +- tests/boxes/stbox_test.py | 477 ++++++++++++---------- tests/main/tgeogpoint_test.py | 5 +- tests/main/tgeompoint_test.py | 56 +-- 31 files changed, 528 insertions(+), 568 deletions(-) create mode 100644 .github/workflows/black.yml diff --git a/.github/workflows/black.yml b/.github/workflows/black.yml new file mode 100644 index 00000000..6b3664b4 --- /dev/null +++ b/.github/workflows/black.yml @@ -0,0 +1,20 @@ +name: Lint code with Black + +on: + push: + branches: [ "master", "stable-[0-9]+.[0-9]+" ] + pull_request: + branches: [ "master", "stable-[0-9]+.[0-9]+" ] + +jobs: + lint: + name: Lint code with Black + runs-on: ubuntu-latest + steps: + - name: Checkout sources + uses: actions/checkout@v4 + + - name: Run Black + uses: psf/black@stable + with: + version: "~= 24.0" \ No newline at end of file diff --git a/docs/conf.py b/docs/conf.py index 5a156062..22f5f208 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -6,47 +6,52 @@ # -- Project information ----------------------------------------------------- # https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information -project = 'PyMEOS' -copyright = '2023, Víctor Diví' -author = 'Víctor Diví' -release = '1.1.3' +project = "PyMEOS" +copyright = "2023, Víctor Diví" +author = "Víctor Diví" +release = "1.1.4" # -- General configuration --------------------------------------------------- # https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration import os import sys -sys.path.insert(0, os.path.abspath('../pymeos_cffi')) -sys.path.insert(0, os.path.abspath('../pymeos')) +sys.path.insert(0, os.path.abspath("../pymeos_cffi")) +sys.path.insert(0, os.path.abspath("../pymeos")) extensions = [ - 'sphinx.ext.autodoc', - 'sphinx.ext.napoleon', - 'sphinx.ext.intersphinx', - 'myst_nb', + "sphinx.ext.autodoc", + "sphinx.ext.napoleon", + "sphinx.ext.intersphinx", + "myst_nb", ] nb_execution_mode = "off" -templates_path = ['_templates'] -exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store', '_build', - '**.ipynb_checkpoints'] -autodoc_member_order = 'bysource' +templates_path = ["_templates"] +exclude_patterns = [ + "_build", + "Thumbs.db", + ".DS_Store", + "_build", + "**.ipynb_checkpoints", +] +autodoc_member_order = "bysource" # -- Intersphinx config -------- intersphinx_mapping = { - 'asyncpg': ('https://magicstack.github.io/asyncpg/current/', None), - 'psycopg': ('https://www.psycopg.org/psycopg3/docs/', None), - 'psycopg2': ('https://www.psycopg.org/docs/', None), - 'shapely': ('https://shapely.readthedocs.io/en/stable/', None), - 'python': ('https://docs.python.org/3', None) + "asyncpg": ("https://magicstack.github.io/asyncpg/current/", None), + "psycopg": ("https://www.psycopg.org/psycopg3/docs/", None), + "psycopg2": ("https://www.psycopg.org/docs/", None), + "shapely": ("https://shapely.readthedocs.io/en/stable/", None), + "python": ("https://docs.python.org/3", None), } # -- Options for HTML output ------------------------------------------------- # https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output -html_theme = 'sphinx_book_theme' -html_static_path = ['_static'] +html_theme = "sphinx_book_theme" +html_static_path = ["_static"] import requests @@ -58,15 +63,13 @@ def download_file(url, dest_path): # Ensure folder for destination file exists os.makedirs(os.path.dirname(dest_path), exist_ok=True) - with open(dest_path, 'wb') as file: + with open(dest_path, "wb") as file: for chunk in response.iter_content(chunk_size=8192): file.write(chunk) prefix = "https://raw.githubusercontent.com/MobilityDB/PyMEOS-Examples/main/" +download_file(f"{prefix}PyMEOS_Examples/AIS.ipynb", "src/examples/AIS.ipynb") download_file( - f"{prefix}PyMEOS_Examples/AIS.ipynb", - "src/examples/AIS.ipynb") -download_file( - f"{prefix}PyMEOS_Examples/BerlinMOD.ipynb", - "src/examples/BerlinMOD.ipynb") + f"{prefix}PyMEOS_Examples/BerlinMOD.ipynb", "src/examples/BerlinMOD.ipynb" +) diff --git a/pymeos/__init__.py b/pymeos/__init__.py index 438a5430..5073293d 100644 --- a/pymeos/__init__.py +++ b/pymeos/__init__.py @@ -29,7 +29,7 @@ MeosGeoJsonOutputError, ) -__version__ = "1.1.3" +__version__ = "1.1.4" __all__ = [ # initialization "pymeos_initialize", diff --git a/pymeos/aggregators/aggregator.py b/pymeos/aggregators/aggregator.py index d6421655..ebe1f249 100644 --- a/pymeos/aggregators/aggregator.py +++ b/pymeos/aggregators/aggregator.py @@ -244,9 +244,7 @@ def _add( interval_converted = ( timedelta_to_interval(interval) if isinstance(interval, timedelta) - else pg_interval_in(interval, -1) - if isinstance(interval, str) - else None + else pg_interval_in(interval, -1) if isinstance(interval, str) else None ) origin_converted = ( datetime_to_timestamptz(origin) diff --git a/pymeos/boxes/stbox.py b/pymeos/boxes/stbox.py index 0f1f1a51..488f79c8 100644 --- a/pymeos/boxes/stbox.py +++ b/pymeos/boxes/stbox.py @@ -41,10 +41,10 @@ class STBox: _mobilitydb_name = "stbox" def _get_box( - self, - other: Union[shp.BaseGeometry, STBox, Temporal, Time], - allow_space_only: bool = True, - allow_time_only: bool = False, + self, + other: Union[shp.BaseGeometry, STBox, Temporal, Time], + allow_space_only: bool = True, + allow_time_only: bool = False, ) -> STBox: if allow_space_only and isinstance(other, shp.BaseGeometry): other_box = geo_to_stbox(geo_to_gserialized(other, self.geodetic())) @@ -68,31 +68,31 @@ def _get_box( # ------------------------- Constructors ---------------------------------- def __init__( - self, - string: Optional[str] = None, - *, - xmin: Optional[Union[str, float]] = None, - xmax: Optional[Union[str, float]] = None, - ymin: Optional[Union[str, float]] = None, - ymax: Optional[Union[str, float]] = None, - zmin: Optional[Union[str, float]] = None, - zmax: Optional[Union[str, float]] = None, - tmin: Optional[Union[str, datetime]] = None, - tmax: Optional[Union[str, datetime]] = None, - tmin_inc: bool = True, - tmax_inc: bool = True, - geodetic: bool = False, - srid: Optional[int] = None, - _inner=None, + self, + string: Optional[str] = None, + *, + xmin: Optional[Union[str, float]] = None, + xmax: Optional[Union[str, float]] = None, + ymin: Optional[Union[str, float]] = None, + ymax: Optional[Union[str, float]] = None, + zmin: Optional[Union[str, float]] = None, + zmax: Optional[Union[str, float]] = None, + tmin: Optional[Union[str, datetime]] = None, + tmax: Optional[Union[str, datetime]] = None, + tmin_inc: bool = True, + tmax_inc: bool = True, + geodetic: bool = False, + srid: Optional[int] = None, + _inner=None, ): assert (_inner is not None) or (string is not None) != ( - ( - xmin is not None - and xmax is not None - and ymin is not None - and ymax is not None - ) - or (tmin is not None and tmax is not None) + ( + xmin is not None + and xmax is not None + and ymin is not None + and ymax is not None + ) + or (tmin is not None and tmax is not None) ), ( "Either string must be not None or at least a bound pair (xmin/max" " and ymin/max, or tmin/max) must be not None" @@ -106,10 +106,10 @@ def __init__( tstzspan = None hast = tmin is not None and tmax is not None hasx = ( - xmin is not None - and xmax is not None - and ymin is not None - and ymax is not None + xmin is not None + and xmax is not None + and ymin is not None + and ymax is not None ) hasz = zmin is not None and zmax is not None if hast: @@ -224,9 +224,9 @@ def from_time(time: Time) -> STBox: @staticmethod def from_geometry_time( - geometry: shp.BaseGeometry, - time: Union[datetime, TsTzSpan], - geodetic: bool = False, + geometry: shp.BaseGeometry, + time: Union[datetime, TsTzSpan], + geodetic: bool = False, ) -> STBox: """ Returns a `STBox` from a space and time dimension. @@ -272,9 +272,9 @@ def from_tpoint(temporal: TPoint) -> STBox: @staticmethod def from_expanding_bounding_box( - value: Union[shp.BaseGeometry, TPoint, STBox], - expansion: float, - geodetic: Optional[bool] = False, + value: Union[shp.BaseGeometry, TPoint, STBox], + expansion: float, + geodetic: Optional[bool] = False, ) -> STBox: """ Returns a `STBox` from a `shp.BaseGeometry`, `TPoint` or `STBox` instance, @@ -661,7 +661,7 @@ def scale_time(self, duration: timedelta) -> STBox: return self.shift_scale_time(duration=duration) def shift_scale_time( - self, shift: Optional[timedelta] = None, duration: Optional[timedelta] = None + self, shift: Optional[timedelta] = None, duration: Optional[timedelta] = None ) -> STBox: """ Returns a new `STBox` with the time dimension shifted by `shift` and @@ -681,7 +681,7 @@ def shift_scale_time( :meth:`TsTzSpan.shift_scale` """ assert ( - shift is not None or duration is not None + shift is not None or duration is not None ), "shift and scale deltas must not be both None" result = stbox_shift_scale_time( self._inner, @@ -792,7 +792,7 @@ def __mul__(self, other): # ------------------------- Topological Operations ------------------------ def is_adjacent( - self, other: Union[shp.BaseGeometry, STBox, Temporal, Time] + self, other: Union[shp.BaseGeometry, STBox, Temporal, Time] ) -> bool: """ Returns whether ``self`` and `other` are adjacent. Two spatiotemporal @@ -815,7 +815,7 @@ def is_adjacent( ) def is_contained_in( - self, container: Union[shp.BaseGeometry, STBox, Temporal, Time] + self, container: Union[shp.BaseGeometry, STBox, Temporal, Time] ) -> bool: """ Returns whether ``self`` is contained in `container`. Note that for @@ -1177,7 +1177,7 @@ def is_over_or_after(self, other: Union[Box, Temporal, Time]) -> bool: # ------------------------- Distance Operations --------------------------- def nearest_approach_distance( - self, other: Union[shp.BaseGeometry, STBox, TPoint] + self, other: Union[shp.BaseGeometry, STBox, TPoint] ) -> float: """ Returns the distance between the nearest points of ``self`` and `other`. @@ -1277,11 +1277,11 @@ def quad_split(self) -> Union[List[List[STBox]], List[List[List[STBox]]]]: ] def tile( - self, - size: Optional[float] = None, - duration: Optional[Union[timedelta, str]] = None, - origin: Optional[shp.BaseGeometry] = None, - start: Union[datetime, str, None] = None, + self, + size: Optional[float] = None, + duration: Optional[Union[timedelta, str]] = None, + origin: Optional[shp.BaseGeometry] = None, + start: Union[datetime, str, None] = None, ) -> List[STBox]: """ Returns a list of `STBox` instances representing the tiles of @@ -1306,35 +1306,35 @@ def tile( stbox_tile_list """ sz = size or ( - max( - self.xmax() - self.xmin(), - self.ymax() - self.ymin(), - (self.zmax() - self.zmin() if self.has_z() else 0), - ) - + 1 + max( + self.xmax() - self.xmin(), + self.ymax() - self.ymin(), + (self.zmax() - self.zmin() if self.has_z() else 0), + ) + + 1 ) dt = ( timedelta_to_interval(duration) if isinstance(duration, timedelta) - else pg_interval_in(duration, -1) - if isinstance(duration, str) - else None + else pg_interval_in(duration, -1) if isinstance(duration, str) else None ) st = ( datetime_to_timestamptz(start) if isinstance(start, datetime) - else pg_timestamptz_in(start, -1) - if isinstance(start, str) - else pg_timestamptz_in("2000-01-03", -1) - if self.has_t() - else 0 + else ( + pg_timestamptz_in(start, -1) + if isinstance(start, str) + else pg_timestamptz_in("2000-01-03", -1) if self.has_t() else 0 + ) ) gs = ( geo_to_gserialized(origin, self.geodetic()) if origin is not None - else pgis_geography_in("Point(0 0 0)", -1) - if self.geodetic() - else pgis_geometry_in("Point(0 0 0)", -1) + else ( + pgis_geography_in("Point(0 0 0)", -1) + if self.geodetic() + else pgis_geometry_in("Point(0 0 0)", -1) + ) ) tiles, count = stbox_tile_list(self._inner, sz, sz, sz, dt, gs, st) return [STBox(_inner=tiles + i) for i in range(count)] diff --git a/pymeos/boxes/tbox.py b/pymeos/boxes/tbox.py index 204841f9..f8f94446 100644 --- a/pymeos/boxes/tbox.py +++ b/pymeos/boxes/tbox.py @@ -1124,9 +1124,11 @@ def tile( st = ( datetime_to_timestamptz(start) if isinstance(start, datetime) - else pg_timestamptz_in(start, -1) - if isinstance(start, str) - else pg_timestamptz_in("2000-01-03", -1) + else ( + pg_timestamptz_in(start, -1) + if isinstance(start, str) + else pg_timestamptz_in("2000-01-03", -1) + ) ) if self._is_float(): tiles, count = tfloatbox_tile_list(self._inner, size, dt, origin, st) diff --git a/pymeos/collections/base/set.py b/pymeos/collections/base/set.py index d482d224..c0b4163d 100644 --- a/pymeos/collections/base/set.py +++ b/pymeos/collections/base/set.py @@ -146,20 +146,16 @@ def as_hexwkb(self) -> str: # ------------------------- Conversions ----------------------------------- @overload - def to_span(self: Type[IntSet]) -> IntSpan: - ... + def to_span(self: Type[IntSet]) -> IntSpan: ... @overload - def to_span(self: Type[FloatSet]) -> FloatSpan: - ... + def to_span(self: Type[FloatSet]) -> FloatSpan: ... @overload - def to_span(self: Type[TsTzSet]) -> TsTzSpan: - ... + def to_span(self: Type[TsTzSet]) -> TsTzSpan: ... @overload - def to_span(self: Type[DateSet]) -> DateSpan: - ... + def to_span(self: Type[DateSet]) -> DateSpan: ... def to_span(self) -> Span: """ @@ -176,20 +172,16 @@ def to_span(self) -> Span: return _CollectionFactory.create_collection(set_span(self._inner)) @overload - def to_spanset(self: Type[IntSet]) -> IntSpanSet: - ... + def to_spanset(self: Type[IntSet]) -> IntSpanSet: ... @overload - def to_spanset(self: Type[FloatSet]) -> FloatSpanSet: - ... + def to_spanset(self: Type[FloatSet]) -> FloatSpanSet: ... @overload - def to_spanset(self: Type[TsTzSet]) -> TsTzSpanSet: - ... + def to_spanset(self: Type[TsTzSet]) -> TsTzSpanSet: ... @overload - def to_spanset(self: Type[DateSet]) -> DateSpanSet: - ... + def to_spanset(self: Type[DateSet]) -> DateSpanSet: ... def to_spanset(self) -> SpanSet: """ diff --git a/pymeos/collections/geo/geoset.py b/pymeos/collections/geo/geoset.py index 438f5258..043a69ed 100644 --- a/pymeos/collections/geo/geoset.py +++ b/pymeos/collections/geo/geoset.py @@ -197,12 +197,10 @@ def contains(self, content: Union[GeoSet, str]) -> bool: # ------------------------- Set Operations -------------------------------- @overload - def intersection(self, other: shp.Geometry) -> Optional[shp.Geometry]: - ... + def intersection(self, other: shp.Geometry) -> Optional[shp.Geometry]: ... @overload - def intersection(self, other: GeoSet) -> Optional[GeoSet]: - ... + def intersection(self, other: GeoSet) -> Optional[GeoSet]: ... def intersection(self, other): """ @@ -317,10 +315,8 @@ class GeometrySet(GeoSet): _mobilitydb_name = "geomset" _parse_function = geomset_in - _parse_value_function = ( - lambda x: pgis_geometry_in(x, -1) - if isinstance(x, str) - else geometry_to_gserialized(x) + _parse_value_function = lambda x: ( + pgis_geometry_in(x, -1) if isinstance(x, str) else geometry_to_gserialized(x) ) @@ -328,8 +324,6 @@ class GeographySet(GeoSet): _mobilitydb_name = "geogset" _parse_function = geogset_in - _parse_value_function = ( - lambda x: pgis_geography_in(x, -1) - if isinstance(x, str) - else geography_to_gserialized(x) + _parse_value_function = lambda x: ( + pgis_geography_in(x, -1) if isinstance(x, str) else geography_to_gserialized(x) ) diff --git a/pymeos/collections/number/floatset.py b/pymeos/collections/number/floatset.py index e1f4de02..000241e8 100644 --- a/pymeos/collections/number/floatset.py +++ b/pymeos/collections/number/floatset.py @@ -301,12 +301,10 @@ def is_over_or_right(self, content: Union[FloatSet, float]) -> bool: # ------------------------- Set Operations -------------------------------- @overload - def intersection(self, other: float) -> Optional[float]: - ... + def intersection(self, other: float) -> Optional[float]: ... @overload - def intersection(self, other: FloatSet) -> Optional[FloatSet]: - ... + def intersection(self, other: FloatSet) -> Optional[FloatSet]: ... def intersection(self, other): """ diff --git a/pymeos/collections/number/floatspan.py b/pymeos/collections/number/floatspan.py index df7a4b1f..c14f3241 100644 --- a/pymeos/collections/number/floatspan.py +++ b/pymeos/collections/number/floatspan.py @@ -377,16 +377,13 @@ def distance( # ------------------------- Set Operations -------------------------------- @overload - def intersection(self, other: Union[int, float]) -> Optional[float]: - ... + def intersection(self, other: Union[int, float]) -> Optional[float]: ... @overload - def intersection(self, other: FloatSpan) -> Optional[FloatSpan]: - ... + def intersection(self, other: FloatSpan) -> Optional[FloatSpan]: ... @overload - def intersection(self, other: FloatSpanSet) -> Optional[FloatSpanSet]: - ... + def intersection(self, other: FloatSpanSet) -> Optional[FloatSpanSet]: ... def intersection(self, other): """ diff --git a/pymeos/collections/number/floatspanset.py b/pymeos/collections/number/floatspanset.py index ec67089a..98d18ee0 100644 --- a/pymeos/collections/number/floatspanset.py +++ b/pymeos/collections/number/floatspanset.py @@ -55,10 +55,8 @@ class FloatSpanSet(SpanSet[float]): _mobilitydb_name = "floatspanset" _parse_function = floatspanset_in - _parse_value_function = ( - lambda span: floatspanset_in(span)[0] - if isinstance(span, str) - else span._inner[0] + _parse_value_function = lambda span: ( + floatspanset_in(span)[0] if isinstance(span, str) else span._inner[0] ) # ------------------------- Output ---------------------------------------- @@ -410,16 +408,13 @@ def distance( # ------------------------- Set Operations -------------------------------- @overload - def intersection(self, other: Union[int, float]) -> Optional[float]: - ... + def intersection(self, other: Union[int, float]) -> Optional[float]: ... @overload - def intersection(self, other: FloatSpan) -> Optional[FloatSpanSet]: - ... + def intersection(self, other: FloatSpan) -> Optional[FloatSpanSet]: ... @overload - def intersection(self, other: FloatSpanSet) -> Optional[FloatSpanSet]: - ... + def intersection(self, other: FloatSpanSet) -> Optional[FloatSpanSet]: ... def intersection(self, other): """ diff --git a/pymeos/collections/number/intset.py b/pymeos/collections/number/intset.py index 47b6016b..0c20b377 100644 --- a/pymeos/collections/number/intset.py +++ b/pymeos/collections/number/intset.py @@ -299,12 +299,10 @@ def is_over_or_right(self, content: Union[IntSet, int]) -> bool: # ------------------------- Set Operations -------------------------------- @overload - def intersection(self, other: int) -> Optional[int]: - ... + def intersection(self, other: int) -> Optional[int]: ... @overload - def intersection(self, other: IntSet) -> Optional[IntSet]: - ... + def intersection(self, other: IntSet) -> Optional[IntSet]: ... def intersection(self, other): """ diff --git a/pymeos/collections/number/intspan.py b/pymeos/collections/number/intspan.py index 49a7d34d..e9b06e39 100644 --- a/pymeos/collections/number/intspan.py +++ b/pymeos/collections/number/intspan.py @@ -368,16 +368,13 @@ def distance(self, other: Union[int, IntSet, IntSpan, IntSpanSet]) -> int: # ------------------------- Set Operations -------------------------------- @overload - def intersection(self, other: int) -> Optional[int]: - ... + def intersection(self, other: int) -> Optional[int]: ... @overload - def intersection(self, other: IntSpan) -> Optional[IntSpan]: - ... + def intersection(self, other: IntSpan) -> Optional[IntSpan]: ... @overload - def intersection(self, other: IntSpanSet) -> Optional[IntSpanSet]: - ... + def intersection(self, other: IntSpanSet) -> Optional[IntSpanSet]: ... def intersection(self, other): """ diff --git a/pymeos/collections/number/intspanset.py b/pymeos/collections/number/intspanset.py index 36248423..ed559738 100644 --- a/pymeos/collections/number/intspanset.py +++ b/pymeos/collections/number/intspanset.py @@ -55,8 +55,8 @@ class IntSpanSet(SpanSet[int]): _mobilitydb_name = "intspanset" _parse_function = intspanset_in - _parse_value_function = ( - lambda span: intspanset_in(span)[0] if isinstance(span, str) else span._inner[0] + _parse_value_function = lambda span: ( + intspanset_in(span)[0] if isinstance(span, str) else span._inner[0] ) # ------------------------- Output ---------------------------------------- @@ -403,16 +403,13 @@ def distance(self, other: Union[int, IntSet, IntSpan, IntSpanSet]) -> int: # ------------------------- Set Operations -------------------------------- @overload - def intersection(self, other: int) -> Optional[int]: - ... + def intersection(self, other: int) -> Optional[int]: ... @overload - def intersection(self, other: IntSpan) -> Optional[IntSpanSet]: - ... + def intersection(self, other: IntSpan) -> Optional[IntSpanSet]: ... @overload - def intersection(self, other: IntSpanSet) -> Optional[IntSpanSet]: - ... + def intersection(self, other: IntSpanSet) -> Optional[IntSpanSet]: ... def intersection(self, other): """ diff --git a/pymeos/collections/text/textset.py b/pymeos/collections/text/textset.py index f6974264..f58e1af9 100644 --- a/pymeos/collections/text/textset.py +++ b/pymeos/collections/text/textset.py @@ -158,12 +158,10 @@ def uppercase(self): # ------------------------- Set Operations -------------------------------- @overload - def intersection(self, other: str) -> Optional[str]: - ... + def intersection(self, other: str) -> Optional[str]: ... @overload - def intersection(self, other: TextSet) -> Optional[TextSet]: - ... + def intersection(self, other: TextSet) -> Optional[TextSet]: ... def intersection(self, other): """ diff --git a/pymeos/collections/time/dateset.py b/pymeos/collections/time/dateset.py index 1e98954f..55def40a 100644 --- a/pymeos/collections/time/dateset.py +++ b/pymeos/collections/time/dateset.py @@ -67,8 +67,8 @@ class DateSet(Set[date], TimeCollection[date]): _mobilitydb_name = "dateset" _parse_function = dateset_in - _parse_value_function = ( - lambda x: pg_date_in(x) if isinstance(x, str) else date_to_date_adt(x) + _parse_value_function = lambda x: ( + pg_date_in(x) if isinstance(x, str) else date_to_date_adt(x) ) _make_function = dateset_make @@ -243,16 +243,12 @@ def shift_scale( shift = ( shift.days if isinstance(shift, timedelta) - else int(shift) - if shift is not None - else 0 + else int(shift) if shift is not None else 0 ) duration = ( duration.days if isinstance(duration, timedelta) - else int(duration) - if duration is not None - else 0 + else int(duration) if duration is not None else 0 ) tss = dateset_shift_scale( self._inner, shift, duration, shift != 0, duration != 0 @@ -507,9 +503,7 @@ def distance(self, other: TimeDate) -> timedelta: days=distance_set_date(self._inner, date_to_date_adt(other)) ) elif isinstance(other, DateSet): - return timedelta( - days=distance_dateset_dateset(self._inner, other._inner) - ) + return timedelta(days=distance_dateset_dateset(self._inner, other._inner)) elif isinstance(other, DateSpan): return self.to_spanset().distance(other) elif isinstance(other, DateSpanSet): @@ -520,14 +514,12 @@ def distance(self, other: TimeDate) -> timedelta: # ------------------------- Set Operations -------------------------------- @overload - def intersection(self, other: Union[date, DateSet]) -> Optional[DateSet]: - ... + def intersection(self, other: Union[date, DateSet]) -> Optional[DateSet]: ... @overload def intersection( self, other: Union[DateSpan, DateSpanSet] - ) -> Optional[DateSpanSet]: - ... + ) -> Optional[DateSpanSet]: ... def intersection(self, other: TimeDate) -> Optional[TimeDate]: """ @@ -560,12 +552,10 @@ def intersection(self, other: TimeDate) -> Optional[TimeDate]: return super().intersection(other) @overload - def minus(self, other: Union[date, DateSet]) -> Optional[DateSet]: - ... + def minus(self, other: Union[date, DateSet]) -> Optional[DateSet]: ... @overload - def minus(self, other: Union[DateSpan, DateSpanSet]) -> Optional[DateSpanSet]: - ... + def minus(self, other: Union[DateSpan, DateSpanSet]) -> Optional[DateSpanSet]: ... def minus(self, other: TimeDate) -> Optional[TimeDate]: """ @@ -616,12 +606,10 @@ def subtract_from(self, other: date) -> Optional[date]: return date_adt_to_date(minus_date_set(date_to_date_adt(other), self._inner)) @overload - def union(self, other: Union[date, DateSet]) -> DateSet: - ... + def union(self, other: Union[date, DateSet]) -> DateSet: ... @overload - def union(self, other: Union[DateSpan, DateSpanSet]) -> DateSpanSet: - ... + def union(self, other: Union[DateSpan, DateSpanSet]) -> DateSpanSet: ... def union(self, other: TimeDate) -> Union[DateSpanSet, DateSet]: """ diff --git a/pymeos/collections/time/datespan.py b/pymeos/collections/time/datespan.py index 85c57b4b..1639b6f9 100644 --- a/pymeos/collections/time/datespan.py +++ b/pymeos/collections/time/datespan.py @@ -69,8 +69,8 @@ class DateSpan(Span[date], TimeCollection[date]): _mobilitydb_name = "datespan" _parse_function = datespan_in - _parse_value_function = ( - lambda x: pg_date_in(x) if isinstance(x, str) else date_to_date_adt(x) + _parse_value_function = lambda x: ( + pg_date_in(x) if isinstance(x, str) else date_to_date_adt(x) ) _make_function = datespan_make @@ -244,16 +244,12 @@ def shift_scale( shift = ( shift.days if isinstance(shift, timedelta) - else int(shift) - if shift is not None - else 0 + else int(shift) if shift is not None else 0 ) duration = ( duration.days if isinstance(duration, timedelta) - else int(duration) - if duration is not None - else 0 + else int(duration) if duration is not None else 0 ) modified = datespan_shift_scale( @@ -486,16 +482,15 @@ def distance(self, other: TimeDate) -> timedelta: # ------------------------- Set Operations -------------------------------- @overload - def intersection(self, other: date) -> Optional[date]: - ... + def intersection(self, other: date) -> Optional[date]: ... @overload - def intersection(self, other: DateSpan) -> Optional[DateSpan]: - ... + def intersection(self, other: DateSpan) -> Optional[DateSpan]: ... @overload - def intersection(self, other: Union[DateSet, DateSpanSet]) -> Optional[DateSpanSet]: - ... + def intersection( + self, other: Union[DateSet, DateSpanSet] + ) -> Optional[DateSpanSet]: ... def intersection(self, other: TimeDate) -> Optional[TimeDate]: """ diff --git a/pymeos/collections/time/datespanset.py b/pymeos/collections/time/datespanset.py index f4118ad9..8171f587 100644 --- a/pymeos/collections/time/datespanset.py +++ b/pymeos/collections/time/datespanset.py @@ -67,10 +67,8 @@ class DateSpanSet(SpanSet[date], TimeCollection[date]): _mobilitydb_name = "dateSpanSet" _parse_function = datespanset_in - _parse_value_function = ( - lambda tstzspan: datespan_in(tstzspan)[0] - if isinstance(tstzspan, str) - else tstzspan._inner[0] + _parse_value_function = lambda tstzspan: ( + datespan_in(tstzspan)[0] if isinstance(tstzspan, str) else tstzspan._inner[0] ) # ------------------------- Output ---------------------------------------- @@ -323,16 +321,12 @@ def shift_scale( shift = ( shift.days if isinstance(shift, timedelta) - else int(shift) - if shift is not None - else 0 + else int(shift) if shift is not None else 0 ) duration = ( duration.days if isinstance(duration, timedelta) - else int(duration) - if duration is not None - else 0 + else int(duration) if duration is not None else 0 ) modified = datespanset_shift_scale( @@ -547,12 +541,10 @@ def distance(self, other: TimeDate) -> timedelta: # ------------------------- Set Operations -------------------------------- @overload - def intersection(self, other: date) -> date: - ... + def intersection(self, other: date) -> date: ... @overload - def intersection(self, other: Union[DateSpan, DateSpanSet]) -> DateSpanSet: - ... + def intersection(self, other: Union[DateSpan, DateSpanSet]) -> DateSpanSet: ... def intersection(self, other: TimeDate) -> Union[date, DateSpanSet]: """ diff --git a/pymeos/collections/time/tstzset.py b/pymeos/collections/time/tstzset.py index 06f009d6..6c91af52 100644 --- a/pymeos/collections/time/tstzset.py +++ b/pymeos/collections/time/tstzset.py @@ -40,10 +40,8 @@ class TsTzSet(Set[datetime], TimeCollection[datetime]): _mobilitydb_name = "tstzset" _parse_function = tstzset_in - _parse_value_function = ( - lambda x: pg_timestamptz_in(x, -1) - if isinstance(x, str) - else datetime_to_timestamptz(x) + _parse_value_function = lambda x: ( + pg_timestamptz_in(x, -1) if isinstance(x, str) else datetime_to_timestamptz(x) ) _make_function = tstzset_make @@ -559,18 +557,15 @@ def distance(self, other: Union[Time, Temporal, Box]) -> timedelta: # ------------------------- Set Operations -------------------------------- @overload - def intersection(self, other: datetime) -> Optional[datetime]: - ... + def intersection(self, other: datetime) -> Optional[datetime]: ... @overload - def intersection(self, other: TsTzSet) -> Optional[TsTzSet]: - ... + def intersection(self, other: TsTzSet) -> Optional[TsTzSet]: ... @overload def intersection( self, other: Union[TsTzSpan, TsTzSpanSet, Temporal, Box] - ) -> Optional[TsTzSpanSet]: - ... + ) -> Optional[TsTzSpanSet]: ... def intersection(self, other: Union[Time, Temporal]) -> Optional[Time]: """ @@ -609,14 +604,12 @@ def intersection(self, other: Union[Time, Temporal]) -> Optional[Time]: return super().intersection(other) @overload - def minus(self, other: Union[datetime, TsTzSet]) -> Optional[TsTzSet]: - ... + def minus(self, other: Union[datetime, TsTzSet]) -> Optional[TsTzSet]: ... @overload def minus( self, other: Union[TsTzSpan, TsTzSpanSet, Temporal, Box] - ) -> Optional[TsTzSpanSet]: - ... + ) -> Optional[TsTzSpanSet]: ... def minus(self, other: Union[Time, Temporal, Box]) -> Optional[Time]: """ @@ -673,12 +666,12 @@ def subtract_from(self, other: datetime) -> Optional[datetime]: ) @overload - def union(self, other: Union[datetime, TsTzSet]) -> TsTzSet: - ... + def union(self, other: Union[datetime, TsTzSet]) -> TsTzSet: ... @overload - def union(self, other: Union[TsTzSpan, TsTzSpanSet, Temporal, Box]) -> TsTzSpanSet: - ... + def union( + self, other: Union[TsTzSpan, TsTzSpanSet, Temporal, Box] + ) -> TsTzSpanSet: ... def union(self, other: Union[Time, Temporal, Box]) -> Union[TsTzSpanSet, TsTzSet]: """ diff --git a/pymeos/collections/time/tstzspan.py b/pymeos/collections/time/tstzspan.py index 9e553ca1..feeaab14 100644 --- a/pymeos/collections/time/tstzspan.py +++ b/pymeos/collections/time/tstzspan.py @@ -42,10 +42,8 @@ class TsTzSpan(Span[datetime], TimeCollection[datetime]): _mobilitydb_name = "tstzspan" _parse_function = tstzspan_in - _parse_value_function = ( - lambda x: pg_timestamptz_in(x, -1) - if isinstance(x, str) - else datetime_to_timestamptz(x) + _parse_value_function = lambda x: ( + pg_timestamptz_in(x, -1) if isinstance(x, str) else datetime_to_timestamptz(x) ) _make_function = tstzspan_make @@ -556,16 +554,15 @@ def distance(self, other: Union[Time, Box, Temporal]) -> timedelta: # ------------------------- Set Operations -------------------------------- @overload - def intersection(self, other: datetime) -> Optional[datetime]: - ... + def intersection(self, other: datetime) -> Optional[datetime]: ... @overload - def intersection(self, other: TsTzSpan) -> Optional[TsTzSpan]: - ... + def intersection(self, other: TsTzSpan) -> Optional[TsTzSpan]: ... @overload - def intersection(self, other: Union[TsTzSet, TsTzSpanSet]) -> Optional[TsTzSpanSet]: - ... + def intersection( + self, other: Union[TsTzSet, TsTzSpanSet] + ) -> Optional[TsTzSpanSet]: ... def intersection(self, other: Time) -> Optional[Time]: """ diff --git a/pymeos/collections/time/tstzspanset.py b/pymeos/collections/time/tstzspanset.py index 624e22f2..95e91d2e 100644 --- a/pymeos/collections/time/tstzspanset.py +++ b/pymeos/collections/time/tstzspanset.py @@ -41,10 +41,8 @@ class TsTzSpanSet(SpanSet[datetime], TimeCollection[datetime]): _mobilitydb_name = "tstzspanset" _parse_function = tstzspanset_in - _parse_value_function = ( - lambda tstzspan: tstzspan_in(tstzspan)[0] - if isinstance(tstzspan, str) - else tstzspan._inner[0] + _parse_value_function = lambda tstzspan: ( + tstzspan_in(tstzspan)[0] if isinstance(tstzspan, str) else tstzspan._inner[0] ) # ------------------------- Output ---------------------------------------- @@ -678,16 +676,13 @@ def distance(self, other: Union[Time, Box, Temporal]) -> timedelta: # ------------------------- Set Operations -------------------------------- @overload - def intersection(self, other: TsTzSpan) -> TsTzSpanSet: - ... + def intersection(self, other: TsTzSpan) -> TsTzSpanSet: ... @overload - def intersection(self, other: TsTzSpanSet) -> TsTzSpanSet: - ... + def intersection(self, other: TsTzSpanSet) -> TsTzSpanSet: ... @overload - def intersection(self, other: datetime) -> datetime: - ... + def intersection(self, other: datetime) -> datetime: ... def intersection(self, other: Time) -> Union[TsTzSpanSet, datetime, TsTzSet]: """ diff --git a/pymeos/main/tbool.py b/pymeos/main/tbool.py index f1466fef..6f9c1673 100644 --- a/pymeos/main/tbool.py +++ b/pymeos/main/tbool.py @@ -46,18 +46,15 @@ def from_base_temporal(value: bool, base: Temporal) -> TBool: @staticmethod @overload - def from_base_time(value: bool, base: datetime) -> TBoolInst: - ... + def from_base_time(value: bool, base: datetime) -> TBoolInst: ... @staticmethod @overload - def from_base_time(value: bool, base: Union[TsTzSet, TsTzSpan]) -> TBoolSeq: - ... + def from_base_time(value: bool, base: Union[TsTzSet, TsTzSpan]) -> TBoolSeq: ... @staticmethod @overload - def from_base_time(value: bool, base: TsTzSpanSet) -> TBoolSeqSet: - ... + def from_base_time(value: bool, base: TsTzSpanSet) -> TBoolSeqSet: ... @staticmethod def from_base_time(value: bool, base: Time) -> TBool: diff --git a/pymeos/main/tfloat.py b/pymeos/main/tfloat.py index e55b962e..6b6e56f6 100644 --- a/pymeos/main/tfloat.py +++ b/pymeos/main/tfloat.py @@ -59,29 +59,25 @@ def from_base_temporal( @overload def from_base_time( value: float, base: datetime, interpolation: None = None - ) -> TFloatInst: - ... + ) -> TFloatInst: ... @staticmethod @overload def from_base_time( value: float, base: TsTzSet, interpolation: None = None - ) -> TFloatSeq: - ... + ) -> TFloatSeq: ... @staticmethod @overload def from_base_time( value: float, base: TsTzSpan, interpolation: TInterpolation = None - ) -> TFloatSeq: - ... + ) -> TFloatSeq: ... @staticmethod @overload def from_base_time( value: float, base: TsTzSpanSet, interpolation: TInterpolation = None - ) -> TFloatSeqSet: - ... + ) -> TFloatSeqSet: ... @staticmethod def from_base_time( diff --git a/pymeos/main/tint.py b/pymeos/main/tint.py index a409818c..f69e7f43 100644 --- a/pymeos/main/tint.py +++ b/pymeos/main/tint.py @@ -51,18 +51,15 @@ def from_base_temporal(value: int, base: Temporal) -> TInt: @staticmethod @overload - def from_base_time(value: int, base: datetime) -> TIntInst: - ... + def from_base_time(value: int, base: datetime) -> TIntInst: ... @staticmethod @overload - def from_base_time(value: int, base: Union[TsTzSet, TsTzSpan]) -> TIntSeq: - ... + def from_base_time(value: int, base: Union[TsTzSet, TsTzSpan]) -> TIntSeq: ... @staticmethod @overload - def from_base_time(value: int, base: TsTzSpanSet) -> TIntSeqSet: - ... + def from_base_time(value: int, base: TsTzSpanSet) -> TIntSeqSet: ... @staticmethod def from_base_time(value: int, base: Time) -> TInt: diff --git a/pymeos/main/tpoint.py b/pymeos/main/tpoint.py index c25f6492..006745fc 100644 --- a/pymeos/main/tpoint.py +++ b/pymeos/main/tpoint.py @@ -1189,9 +1189,11 @@ def space_split( gs = ( geo_to_gserialized(origin, isinstance(self, TGeogPoint)) if origin is not None - else pgis_geography_in("Point(0 0 0)", -1) - if isinstance(self, TGeogPoint) - else pgis_geometry_in("Point(0 0 0)", -1) + else ( + pgis_geography_in("Point(0 0 0)", -1) + if isinstance(self, TGeogPoint) + else pgis_geometry_in("Point(0 0 0)", -1) + ) ) fragments, values, count = tpoint_space_split( self._inner, xsize, ysz, zsz, gs, bitmatrix @@ -1240,9 +1242,11 @@ def space_time_split( gs = ( geo_to_gserialized(origin, isinstance(self, TGeogPoint)) if origin is not None - else pgis_geography_in("Point(0 0 0)", -1) - if isinstance(self, TGeogPoint) - else pgis_geometry_in("Point(0 0 0)", -1) + else ( + pgis_geography_in("Point(0 0 0)", -1) + if isinstance(self, TGeogPoint) + else pgis_geometry_in("Point(0 0 0)", -1) + ) ) if time_start is None: st = pg_timestamptz_in("2000-01-03", -1) @@ -1422,22 +1426,19 @@ def from_base_temporal(value: shpb.BaseGeometry, base: Temporal) -> TGeomPoint: @overload def from_base_time( value: shpb.BaseGeometry, base: datetime, interpolation: None = None - ) -> TGeomPointInst: - ... + ) -> TGeomPointInst: ... @staticmethod @overload def from_base_time( value: shpb.BaseGeometry, base: TsTzSet, interpolation: None = None - ) -> TGeomPointSeq: - ... + ) -> TGeomPointSeq: ... @staticmethod @overload def from_base_time( value: shpb.BaseGeometry, base: TsTzSpan, interpolation: TInterpolation = None - ) -> TGeomPointSeq: - ... + ) -> TGeomPointSeq: ... @staticmethod @overload @@ -1445,8 +1446,7 @@ def from_base_time( value: shpb.BaseGeometry, base: TsTzSpanSet, interpolation: TInterpolation = None, - ) -> TGeomPointSeqSet: - ... + ) -> TGeomPointSeqSet: ... @staticmethod def from_base_time( @@ -1781,22 +1781,19 @@ def from_base_temporal(value: shpb.BaseGeometry, base: Temporal) -> TGeogPoint: @overload def from_base_time( value: shpb.BaseGeometry, base: datetime, interpolation: TInterpolation = None - ) -> TGeogPointInst: - ... + ) -> TGeogPointInst: ... @staticmethod @overload def from_base_time( value: shpb.BaseGeometry, base: TsTzSet, interpolation: TInterpolation = None - ) -> TGeogPointSeq: - ... + ) -> TGeogPointSeq: ... @staticmethod @overload def from_base_time( value: shpb.BaseGeometry, base: TsTzSpan, interpolation: TInterpolation = None - ) -> TGeogPointSeq: - ... + ) -> TGeogPointSeq: ... @staticmethod @overload @@ -1804,8 +1801,7 @@ def from_base_time( value: shpb.BaseGeometry, base: TsTzSpanSet, interpolation: TInterpolation = None, - ) -> TGeogPointSeqSet: - ... + ) -> TGeogPointSeqSet: ... @staticmethod def from_base_time( diff --git a/pymeos/main/ttext.py b/pymeos/main/ttext.py index ef373c73..d0450abd 100644 --- a/pymeos/main/ttext.py +++ b/pymeos/main/ttext.py @@ -52,18 +52,15 @@ def from_base_temporal(value: str, base: Temporal) -> TText: @staticmethod @overload - def from_base_time(value: str, base: datetime) -> TTextInst: - ... + def from_base_time(value: str, base: datetime) -> TTextInst: ... @staticmethod @overload - def from_base_time(value: str, base: Union[TsTzSet, TsTzSpan]) -> TTextSeq: - ... + def from_base_time(value: str, base: Union[TsTzSet, TsTzSpan]) -> TTextSeq: ... @staticmethod @overload - def from_base_time(value: str, base: TsTzSpanSet) -> TTextSeqSet: - ... + def from_base_time(value: str, base: TsTzSpanSet) -> TTextSeqSet: ... @staticmethod def from_base_time(value: str, base: Time) -> TText: diff --git a/pymeos/temporal/tsequence.py b/pymeos/temporal/tsequence.py index 80d02a18..35578ccc 100644 --- a/pymeos/temporal/tsequence.py +++ b/pymeos/temporal/tsequence.py @@ -43,9 +43,11 @@ def __init__( self._inner = as_tsequence(self.__class__._parse_function(string)) else: self._instants = [ - x._inner - if isinstance(x, self.ComponentClass) - else self.__class__._parse_function(x) + ( + x._inner + if isinstance(x, self.ComponentClass) + else self.__class__._parse_function(x) + ) for x in instant_list ] count = len(self._instants) diff --git a/pymeos/temporal/tsequenceset.py b/pymeos/temporal/tsequenceset.py index eb02fc83..b9213130 100644 --- a/pymeos/temporal/tsequenceset.py +++ b/pymeos/temporal/tsequenceset.py @@ -43,9 +43,11 @@ def __init__( self._inner = as_tsequenceset(self.__class__._parse_function(string)) else: sequences = [ - x._inner - if isinstance(x, self.ComponentClass) - else self.__class__._parse_function(x) + ( + x._inner + if isinstance(x, self.ComponentClass) + else self.__class__._parse_function(x) + ) for x in sequence_list ] count = len(sequences) diff --git a/tests/boxes/stbox_test.py b/tests/boxes/stbox_test.py index 5a150c98..cdc109f3 100644 --- a/tests/boxes/stbox_test.py +++ b/tests/boxes/stbox_test.py @@ -39,14 +39,14 @@ class TestSTBoxConstructors(TestSTBox): [ ("STBox X((1,1),(2,2))", STBox, "STBOX X((1,1),(2,2))"), ( - "STBox T([2019-09-01,2019-09-02])", - STBox, - "STBOX T([2019-09-01 00:00:00+00, 2019-09-02 00:00:00+00])", + "STBox T([2019-09-01,2019-09-02])", + STBox, + "STBOX T([2019-09-01 00:00:00+00, 2019-09-02 00:00:00+00])", ), ( - "STBox XT(((1,1),(2,2)),[2019-09-01,2019-09-02])", - STBox, - "STBOX XT(((1,1),(2,2)),[2019-09-01 00:00:00+00, 2019-09-02 00:00:00+00])", + "STBox XT(((1,1),(2,2)),[2019-09-01,2019-09-02])", + STBox, + "STBOX XT(((1,1),(2,2)),[2019-09-01 00:00:00+00, 2019-09-02 00:00:00+00])", ), ], ids=["STBox X", "STBox T", "STBox XT"], @@ -62,12 +62,12 @@ def test_string_constructor(self, source, type, expected): (Point(1, 1), "STBOX X((1,1),(1,1))"), (LineString([(1, 1), (2, 2)]), "STBOX X((1,1),(2,2))"), ( - shapely.set_srid(shapely.Point(1, 1), 5676), - "SRID=5676;STBOX X((1,1),(1,1))", + shapely.set_srid(shapely.Point(1, 1), 5676), + "SRID=5676;STBOX X((1,1),(1,1))", ), ( - shapely.set_srid(shapely.LineString([(1, 1), (2, 2)]), 5676), - "SRID=5676;STBOX X((1,1),(2,2))", + shapely.set_srid(shapely.LineString([(1, 1), (2, 2)]), 5676), + "SRID=5676;STBOX X((1,1),(2,2))", ), ], ids=["point", "linestring", "srid point", "srid linestring"], @@ -81,14 +81,41 @@ def test_from_geometry_constructor(self, geometry, expected): "params, expected", [ ({"xmin": 0, "xmax": 2, "ymin": "1", "ymax": "3"}, "STBOX X((0,1),(2,3))"), - ({"xmin": 0, "xmax": 2, "ymin": "1", "ymax": "3", "zmin": 10, "zmax": 12}, - "STBOX Z((0,1,10),(2,3,12))"), - ({"xmin": 0, "xmax": 2, "ymin": "1", "ymax": "3", "tmin": "2000-01-01", - "tmax": "2000-01-03"}, - "STBOX XT(((0,1),(2,3)),[2000-01-01 00:00:00+00, 2000-01-03 00:00:00+00])"), - ({"xmin": 0, "xmax": 2, "ymin": "1", "ymax": "3", "zmin": 10, "zmax": 12, - "tmin": datetime(2000, 1, 1), "tmax": datetime(2000, 1, 3)}, - "STBOX ZT(((0,1,10),(2,3,12)),[2000-01-01 00:00:00+00, 2000-01-03 00:00:00+00])") + ( + { + "xmin": 0, + "xmax": 2, + "ymin": "1", + "ymax": "3", + "zmin": 10, + "zmax": 12, + }, + "STBOX Z((0,1,10),(2,3,12))", + ), + ( + { + "xmin": 0, + "xmax": 2, + "ymin": "1", + "ymax": "3", + "tmin": "2000-01-01", + "tmax": "2000-01-03", + }, + "STBOX XT(((0,1),(2,3)),[2000-01-01 00:00:00+00, 2000-01-03 00:00:00+00])", + ), + ( + { + "xmin": 0, + "xmax": 2, + "ymin": "1", + "ymax": "3", + "zmin": 10, + "zmax": 12, + "tmin": datetime(2000, 1, 1), + "tmax": datetime(2000, 1, 3), + }, + "STBOX ZT(((0,1,10),(2,3,12)),[2000-01-01 00:00:00+00, 2000-01-03 00:00:00+00])", + ), ], ids=["XY", "XYZ", "XYT", "XYZT"], ) @@ -101,20 +128,20 @@ def test_parameters_constructor(self, params, expected): "time, expected", [ ( - datetime(2019, 9, 1), - "STBOX T([2019-09-01 00:00:00+00, 2019-09-01 00:00:00+00])", + datetime(2019, 9, 1), + "STBOX T([2019-09-01 00:00:00+00, 2019-09-01 00:00:00+00])", ), ( - TsTzSet("{2019-09-01, 2019-09-02}"), - "STBOX T([2019-09-01 00:00:00+00, 2019-09-02 00:00:00+00])", + TsTzSet("{2019-09-01, 2019-09-02}"), + "STBOX T([2019-09-01 00:00:00+00, 2019-09-02 00:00:00+00])", ), ( - TsTzSpan("[2019-09-01, 2019-09-02]"), - "STBOX T([2019-09-01 00:00:00+00, 2019-09-02 00:00:00+00])", + TsTzSpan("[2019-09-01, 2019-09-02]"), + "STBOX T([2019-09-01 00:00:00+00, 2019-09-02 00:00:00+00])", ), ( - TsTzSpanSet("{[2019-09-01, 2019-09-02],[2019-09-03, 2019-09-05]}"), - "STBOX T([2019-09-01 00:00:00+00, 2019-09-05 00:00:00+00])", + TsTzSpanSet("{[2019-09-01, 2019-09-02],[2019-09-03, 2019-09-05]}"), + "STBOX T([2019-09-01 00:00:00+00, 2019-09-05 00:00:00+00])", ), ], ids=["Timestamp", "TsTzSet", "TsTzSpan", "TsTzSpanSet"], @@ -128,14 +155,14 @@ def test_from_time_constructor(self, time, expected): "geometry, time, expected", [ ( - Point(1, 1), - datetime(2019, 9, 1), - "STBOX XT(((1,1),(1,1)),[2019-09-01 00:00:00+00, 2019-09-01 00:00:00+00])", + Point(1, 1), + datetime(2019, 9, 1), + "STBOX XT(((1,1),(1,1)),[2019-09-01 00:00:00+00, 2019-09-01 00:00:00+00])", ), ( - Point(1, 1), - TsTzSpan("[2019-09-01, 2019-09-02]"), - "STBOX XT(((1,1),(1,1)),[2019-09-01 00:00:00+00, 2019-09-02 00:00:00+00])", + Point(1, 1), + TsTzSpan("[2019-09-01, 2019-09-02]"), + "STBOX XT(((1,1),(1,1)),[2019-09-01 00:00:00+00, 2019-09-02 00:00:00+00])", ), ], ids=["geometry-Timestamp", "geometry-TsTzSpan"], @@ -149,40 +176,40 @@ def test_from_geometry_time_constructor(self, geometry, time, expected): "tpoint, expected", [ ( - TGeomPointInst("Point(1 1)@2019-09-01"), - "STBOX XT(((1,1),(1,1)),[2019-09-01 00:00:00+00, 2019-09-01 00:00:00+00])", + TGeomPointInst("Point(1 1)@2019-09-01"), + "STBOX XT(((1,1),(1,1)),[2019-09-01 00:00:00+00, 2019-09-01 00:00:00+00])", ), ( - TGeomPointSeq("{Point(1 1)@2019-09-01, Point(2 2)@2019-09-02}"), - "STBOX XT(((1,1),(2,2)),[2019-09-01 00:00:00+00, 2019-09-02 00:00:00+00])", + TGeomPointSeq("{Point(1 1)@2019-09-01, Point(2 2)@2019-09-02}"), + "STBOX XT(((1,1),(2,2)),[2019-09-01 00:00:00+00, 2019-09-02 00:00:00+00])", ), ( - TGeomPointSeq("[Point(1 1)@2019-09-01, Point(2 2)@2019-09-02]"), - "STBOX XT(((1,1),(2,2)),[2019-09-01 00:00:00+00, 2019-09-02 00:00:00+00])", + TGeomPointSeq("[Point(1 1)@2019-09-01, Point(2 2)@2019-09-02]"), + "STBOX XT(((1,1),(2,2)),[2019-09-01 00:00:00+00, 2019-09-02 00:00:00+00])", ), ( - TGeomPointSeqSet( - "{[Point(1 1)@2019-09-01, Point(2 2)@2019-09-02],[Point(1 1)@2019-09-03, Point(1 1)@2019-09-05]}" - ), - "STBOX XT(((1,1),(2,2)),[2019-09-01 00:00:00+00, 2019-09-05 00:00:00+00])", + TGeomPointSeqSet( + "{[Point(1 1)@2019-09-01, Point(2 2)@2019-09-02],[Point(1 1)@2019-09-03, Point(1 1)@2019-09-05]}" + ), + "STBOX XT(((1,1),(2,2)),[2019-09-01 00:00:00+00, 2019-09-05 00:00:00+00])", ), ( - TGeogPointInst("Point(1 1)@2019-09-01"), - "SRID=4326;GEODSTBOX XT(((1,1),(1,1)),[2019-09-01 00:00:00+00, 2019-09-01 00:00:00+00])", + TGeogPointInst("Point(1 1)@2019-09-01"), + "SRID=4326;GEODSTBOX XT(((1,1),(1,1)),[2019-09-01 00:00:00+00, 2019-09-01 00:00:00+00])", ), ( - TGeogPointSeq("{Point(1 1)@2019-09-01, Point(2 2)@2019-09-02}"), - "SRID=4326;GEODSTBOX XT(((1,1),(2,2)),[2019-09-01 00:00:00+00, 2019-09-02 00:00:00+00])", + TGeogPointSeq("{Point(1 1)@2019-09-01, Point(2 2)@2019-09-02}"), + "SRID=4326;GEODSTBOX XT(((1,1),(2,2)),[2019-09-01 00:00:00+00, 2019-09-02 00:00:00+00])", ), ( - TGeogPointSeq("[Point(1 1)@2019-09-01, Point(2 2)@2019-09-02]"), - "SRID=4326;GEODSTBOX XT(((1,1),(2,2)),[2019-09-01 00:00:00+00, 2019-09-02 00:00:00+00])", + TGeogPointSeq("[Point(1 1)@2019-09-01, Point(2 2)@2019-09-02]"), + "SRID=4326;GEODSTBOX XT(((1,1),(2,2)),[2019-09-01 00:00:00+00, 2019-09-02 00:00:00+00])", ), ( - TGeogPointSeqSet( - "{[Point(1 1)@2019-09-01, Point(2 2)@2019-09-02],[Point(1 1)@2019-09-03, Point(1 1)@2019-09-05]}" - ), - "SRID=4326;GEODSTBOX XT(((1,1),(2,2)),[2019-09-01 00:00:00+00, 2019-09-05 00:00:00+00])", + TGeogPointSeqSet( + "{[Point(1 1)@2019-09-01, Point(2 2)@2019-09-02],[Point(1 1)@2019-09-03, Point(1 1)@2019-09-05]}" + ), + "SRID=4326;GEODSTBOX XT(((1,1),(2,2)),[2019-09-01 00:00:00+00, 2019-09-05 00:00:00+00])", ), ], ids=[ @@ -207,12 +234,12 @@ def test_from_tpoint_constructor(self, tpoint, expected): (Point(1, 1), "STBOX X((0,0),(2,2))"), (LineString([(1, 1), (2, 2)]), "STBOX X((0,0),(3,3))"), ( - shapely.set_srid(shapely.Point(1, 1), 5676), - "SRID=5676;STBOX X((0,0),(2,2))", + shapely.set_srid(shapely.Point(1, 1), 5676), + "SRID=5676;STBOX X((0,0),(2,2))", ), ( - shapely.set_srid(shapely.LineString([(1, 1), (2, 2)]), 5676), - "SRID=5676;STBOX X((0,0),(3,3))", + shapely.set_srid(shapely.LineString([(1, 1), (2, 2)]), 5676), + "SRID=5676;STBOX X((0,0),(3,3))", ), ], ids=["Point", "Line string", "Geodetic Point", "Geodetic line string"], @@ -226,40 +253,40 @@ def test_from_geo_expand_space_constructor(self, geo, expected): "tpoint, expected", [ ( - TGeomPointInst("Point(1 1)@2019-09-01"), - "STBOX XT(((0,0),(2,2)),[2019-09-01 00:00:00+00, 2019-09-01 00:00:00+00])", + TGeomPointInst("Point(1 1)@2019-09-01"), + "STBOX XT(((0,0),(2,2)),[2019-09-01 00:00:00+00, 2019-09-01 00:00:00+00])", ), ( - TGeomPointSeq("{Point(1 1)@2019-09-01, Point(2 2)@2019-09-02}"), - "STBOX XT(((0,0),(3,3)),[2019-09-01 00:00:00+00, 2019-09-02 00:00:00+00])", + TGeomPointSeq("{Point(1 1)@2019-09-01, Point(2 2)@2019-09-02}"), + "STBOX XT(((0,0),(3,3)),[2019-09-01 00:00:00+00, 2019-09-02 00:00:00+00])", ), ( - TGeomPointSeq("[Point(1 1)@2019-09-01, Point(2 2)@2019-09-02]"), - "STBOX XT(((0,0),(3,3)),[2019-09-01 00:00:00+00, 2019-09-02 00:00:00+00])", + TGeomPointSeq("[Point(1 1)@2019-09-01, Point(2 2)@2019-09-02]"), + "STBOX XT(((0,0),(3,3)),[2019-09-01 00:00:00+00, 2019-09-02 00:00:00+00])", ), ( - TGeomPointSeqSet( - "{[Point(1 1)@2019-09-01, Point(2 2)@2019-09-02],[Point(1 1)@2019-09-03, Point(1 1)@2019-09-05]}" - ), - "STBOX XT(((0,0),(3,3)),[2019-09-01 00:00:00+00, 2019-09-05 00:00:00+00])", + TGeomPointSeqSet( + "{[Point(1 1)@2019-09-01, Point(2 2)@2019-09-02],[Point(1 1)@2019-09-03, Point(1 1)@2019-09-05]}" + ), + "STBOX XT(((0,0),(3,3)),[2019-09-01 00:00:00+00, 2019-09-05 00:00:00+00])", ), ( - TGeogPointInst("Point(1 1)@2019-09-01"), - "SRID=4326;GEODSTBOX XT(((0,0),(2,2)),[2019-09-01 00:00:00+00, 2019-09-01 00:00:00+00])", + TGeogPointInst("Point(1 1)@2019-09-01"), + "SRID=4326;GEODSTBOX XT(((0,0),(2,2)),[2019-09-01 00:00:00+00, 2019-09-01 00:00:00+00])", ), ( - TGeogPointSeq("{Point(1 1)@2019-09-01, Point(2 2)@2019-09-02}"), - "SRID=4326;GEODSTBOX XT(((0,0),(3,3)),[2019-09-01 00:00:00+00, 2019-09-02 00:00:00+00])", + TGeogPointSeq("{Point(1 1)@2019-09-01, Point(2 2)@2019-09-02}"), + "SRID=4326;GEODSTBOX XT(((0,0),(3,3)),[2019-09-01 00:00:00+00, 2019-09-02 00:00:00+00])", ), ( - TGeogPointSeq("[Point(1 1)@2019-09-01, Point(2 2)@2019-09-02]"), - "SRID=4326;GEODSTBOX XT(((0,0),(3,3)),[2019-09-01 00:00:00+00, 2019-09-02 00:00:00+00])", + TGeogPointSeq("[Point(1 1)@2019-09-01, Point(2 2)@2019-09-02]"), + "SRID=4326;GEODSTBOX XT(((0,0),(3,3)),[2019-09-01 00:00:00+00, 2019-09-02 00:00:00+00])", ), ( - TGeogPointSeqSet( - "{[Point(1 1)@2019-09-01, Point(2 2)@2019-09-02],[Point(1 1)@2019-09-03, Point(1 1)@2019-09-05]}" - ), - "SRID=4326;GEODSTBOX XT(((0,0),(3,3)),[2019-09-01 00:00:00+00, 2019-09-05 00:00:00+00])", + TGeogPointSeqSet( + "{[Point(1 1)@2019-09-01, Point(2 2)@2019-09-02],[Point(1 1)@2019-09-03, Point(1 1)@2019-09-05]}" + ), + "SRID=4326;GEODSTBOX XT(((0,0),(3,3)),[2019-09-01 00:00:00+00, 2019-09-05 00:00:00+00])", ), ], ids=[ @@ -284,12 +311,12 @@ def test_from_tpoint_expand_space_constructor(self, tpoint, expected): (STBox("STBOX X((1,1),(2,2))"), "STBOX X((0,0),(3,3))"), (STBox("STBOX Z((1,1,1),(2,2,2))"), "STBOX Z((0,0,0),(3,3,3))"), ( - STBox("STBOX XT(((1,1),(2,2)),[2019-09-01,2019-09-02])"), - "STBOX XT(((0,0),(3,3)),[2019-09-01 00:00:00+00, 2019-09-02 00:00:00+00])", + STBox("STBOX XT(((1,1),(2,2)),[2019-09-01,2019-09-02])"), + "STBOX XT(((0,0),(3,3)),[2019-09-01 00:00:00+00, 2019-09-02 00:00:00+00])", ), ( - STBox("STBOX ZT(((1,1,1),(2,2,2)),[2019-09-01,2019-09-02])"), - "STBOX ZT(((0,0,0),(3,3,3)),[2019-09-01 00:00:00+00, 2019-09-02 00:00:00+00])", + STBox("STBOX ZT(((1,1,1),(2,2,2)),[2019-09-01,2019-09-02])"), + "STBOX ZT(((0,0,0),(3,3,3)),[2019-09-01 00:00:00+00, 2019-09-02 00:00:00+00])", ), ], ids=["STBox X", "STBox Z", "STBox XT", "STBox ZT"], @@ -303,76 +330,76 @@ def test_from_stbox_expand_space_constructor(self, stbox, expected): "stbox, expected", [ ( - STBox("STBOX X((1,1),(3,3))"), - [ - STBox("STBOX X((1,1),(2,2))"), - STBox("STBOX X((2,1),(3,2))"), - STBox("STBOX X((1,2),(2,3))"), - STBox("STBOX X((2,2),(3,3))"), - ], + STBox("STBOX X((1,1),(3,3))"), + [ + STBox("STBOX X((1,1),(2,2))"), + STBox("STBOX X((2,1),(3,2))"), + STBox("STBOX X((1,2),(2,3))"), + STBox("STBOX X((2,2),(3,3))"), + ], ), ( - STBox("STBOX Z((1,1,1),(3,3,3))"), - [ - STBox("STBOX Z((1,1,1),(2,2,2))"), - STBox("STBOX Z((2,1,1),(3,2,2))"), - STBox("STBOX Z((1,2,1),(2,3,2))"), - STBox("STBOX Z((2,2,1),(3,3,2))"), - STBox("STBOX Z((1,1,2),(2,2,3))"), - STBox("STBOX Z((2,1,2),(3,2,3))"), - STBox("STBOX Z((1,2,2),(2,3,3))"), - STBox("STBOX Z((2,2,2),(3,3,3))"), - ], + STBox("STBOX Z((1,1,1),(3,3,3))"), + [ + STBox("STBOX Z((1,1,1),(2,2,2))"), + STBox("STBOX Z((2,1,1),(3,2,2))"), + STBox("STBOX Z((1,2,1),(2,3,2))"), + STBox("STBOX Z((2,2,1),(3,3,2))"), + STBox("STBOX Z((1,1,2),(2,2,3))"), + STBox("STBOX Z((2,1,2),(3,2,3))"), + STBox("STBOX Z((1,2,2),(2,3,3))"), + STBox("STBOX Z((2,2,2),(3,3,3))"), + ], ), ( + STBox( + "STBOX XT(((1,1),(3,3)),[2019-09-01 00:00:00+00, 2019-09-02 00:00:00+00])" + ), + [ STBox( - "STBOX XT(((1,1),(3,3)),[2019-09-01 00:00:00+00, 2019-09-02 00:00:00+00])" + "STBOX XT(((1,1),(2,2)),[2019-09-01 00:00:00+00, 2019-09-02 00:00:00+00])" ), - [ - STBox( - "STBOX XT(((1,1),(2,2)),[2019-09-01 00:00:00+00, 2019-09-02 00:00:00+00])" - ), - STBox( - "STBOX XT(((2,1),(3,2)),[2019-09-01 00:00:00+00, 2019-09-02 00:00:00+00])" - ), - STBox( - "STBOX XT(((1,2),(2,3)),[2019-09-01 00:00:00+00, 2019-09-02 00:00:00+00])" - ), - STBox( - "STBOX XT(((2,2),(3,3)),[2019-09-01 00:00:00+00, 2019-09-02 00:00:00+00])" - ), - ], + STBox( + "STBOX XT(((2,1),(3,2)),[2019-09-01 00:00:00+00, 2019-09-02 00:00:00+00])" + ), + STBox( + "STBOX XT(((1,2),(2,3)),[2019-09-01 00:00:00+00, 2019-09-02 00:00:00+00])" + ), + STBox( + "STBOX XT(((2,2),(3,3)),[2019-09-01 00:00:00+00, 2019-09-02 00:00:00+00])" + ), + ], ), ( + STBox( + "STBOX ZT(((1,1,1),(3,3,3)),[2019-09-01 00:00:00+00, 2019-09-02 00:00:00+00])" + ), + [ + STBox( + "STBOX ZT(((1,1,1),(2,2,2)),[2019-09-01 00:00:00+00, 2019-09-02 00:00:00+00])" + ), + STBox( + "STBOX ZT(((2,1,1),(3,2,2)),[2019-09-01 00:00:00+00, 2019-09-02 00:00:00+00])" + ), STBox( - "STBOX ZT(((1,1,1),(3,3,3)),[2019-09-01 00:00:00+00, 2019-09-02 00:00:00+00])" + "STBOX ZT(((1,2,1),(2,3,2)),[2019-09-01 00:00:00+00, 2019-09-02 00:00:00+00])" ), - [ - STBox( - "STBOX ZT(((1,1,1),(2,2,2)),[2019-09-01 00:00:00+00, 2019-09-02 00:00:00+00])" - ), - STBox( - "STBOX ZT(((2,1,1),(3,2,2)),[2019-09-01 00:00:00+00, 2019-09-02 00:00:00+00])" - ), - STBox( - "STBOX ZT(((1,2,1),(2,3,2)),[2019-09-01 00:00:00+00, 2019-09-02 00:00:00+00])" - ), - STBox( - "STBOX ZT(((2,2,1),(3,3,2)),[2019-09-01 00:00:00+00, 2019-09-02 00:00:00+00])" - ), - STBox( - "STBOX ZT(((1,1,2),(2,2,3)),[2019-09-01 00:00:00+00, 2019-09-02 00:00:00+00])" - ), - STBox( - "STBOX ZT(((2,1,2),(3,2,3)),[2019-09-01 00:00:00+00, 2019-09-02 00:00:00+00])" - ), - STBox( - "STBOX ZT(((1,2,2),(2,3,3)),[2019-09-01 00:00:00+00, 2019-09-02 00:00:00+00])" - ), - STBox( - "STBOX ZT(((2,2,2),(3,3,3)),[2019-09-01 00:00:00+00, 2019-09-02 00:00:00+00])" - ), - ], + STBox( + "STBOX ZT(((2,2,1),(3,3,2)),[2019-09-01 00:00:00+00, 2019-09-02 00:00:00+00])" + ), + STBox( + "STBOX ZT(((1,1,2),(2,2,3)),[2019-09-01 00:00:00+00, 2019-09-02 00:00:00+00])" + ), + STBox( + "STBOX ZT(((2,1,2),(3,2,3)),[2019-09-01 00:00:00+00, 2019-09-02 00:00:00+00])" + ), + STBox( + "STBOX ZT(((1,2,2),(2,3,3)),[2019-09-01 00:00:00+00, 2019-09-02 00:00:00+00])" + ), + STBox( + "STBOX ZT(((2,2,2),(3,3,3)),[2019-09-01 00:00:00+00, 2019-09-02 00:00:00+00])" + ), + ], ), ], ids=["STBox X", "STBox Z", "STBox XT", "STBox ZT"], @@ -416,12 +443,12 @@ class TestSTBoxOutputs(TestSTBox): (stbz, "STBOX Z((1,1,1),(2,2,2))"), (stbt, "STBOX T([2019-09-01 00:00:00+00, 2019-09-02 00:00:00+00])"), ( - stbxt, - "STBOX XT(((1,1),(2,2)),[2019-09-01 00:00:00+00, 2019-09-02 00:00:00+00])", + stbxt, + "STBOX XT(((1,1),(2,2)),[2019-09-01 00:00:00+00, 2019-09-02 00:00:00+00])", ), ( - stbzt, - "STBOX ZT(((1,1,1),(2,2,2)),[2019-09-01 00:00:00+00, 2019-09-02 00:00:00+00])", + stbzt, + "STBOX ZT(((1,1,1),(2,2,2)),[2019-09-01 00:00:00+00, 2019-09-02 00:00:00+00])", ), ], ids=["STBox X", "STBox Z", "STBox T", "STBox XT", "STBox ZT"], @@ -436,12 +463,12 @@ def test_str(self, stbox, expected): (stbz, "STBox(STBOX Z((1,1,1),(2,2,2)))"), (stbt, "STBox(STBOX T([2019-09-01 00:00:00+00, 2019-09-02 00:00:00+00]))"), ( - stbxt, - "STBox(STBOX XT(((1,1),(2,2)),[2019-09-01 00:00:00+00, 2019-09-02 00:00:00+00]))", + stbxt, + "STBox(STBOX XT(((1,1),(2,2)),[2019-09-01 00:00:00+00, 2019-09-02 00:00:00+00]))", ), ( - stbzt, - "STBox(STBOX ZT(((1,1,1),(2,2,2)),[2019-09-01 00:00:00+00, 2019-09-02 00:00:00+00]))", + stbzt, + "STBox(STBOX ZT(((1,1,1),(2,2,2)),[2019-09-01 00:00:00+00, 2019-09-02 00:00:00+00]))", ), ], ids=["STBox X", "STBox Z", "STBox T", "STBox XT", "STBox ZT"], @@ -453,21 +480,21 @@ def test_repr(self, stbox, expected): "stbox, expected", [ ( - stbx, - "0101000000000000F03F0000000000000040000000000000F03F0000000000000040", + stbx, + "0101000000000000F03F0000000000000040000000000000F03F0000000000000040", ), ( - stbz, - "0111000000000000F03F0000000000000040000000000000F03F0000000000000040000000000000F03F0000000000000040", + stbz, + "0111000000000000F03F0000000000000040000000000000F03F0000000000000040000000000000F03F0000000000000040", ), (stbt, "010227000300A01E4E713402000000F66B85340200"), ( - stbxt, - "010327000300A01E4E713402000000F66B85340200000000000000F03F0000000000000040000000000000F03F0000000000000040", + stbxt, + "010327000300A01E4E713402000000F66B85340200000000000000F03F0000000000000040000000000000F03F0000000000000040", ), ( - stbzt, - "011327000300A01E4E713402000000F66B85340200000000000000F03F0000000000000040000000000000F03F0000000000000040000000000000F03F0000000000000040", + stbzt, + "011327000300A01E4E713402000000F66B85340200000000000000F03F0000000000000040000000000000F03F0000000000000040000000000000F03F0000000000000040", ), ], ids=["STBox X", "STBox Z", "STBox T", "STBox XT", "STBox ZT"], @@ -732,14 +759,14 @@ def test_expand_time(self, stbox, expected): (stbt, timedelta(days=4), STBox("STBOX T([2019-09-05,2019-09-06])")), (stbt, timedelta(days=-4), STBox("STBOX T([2019-08-28,2019-08-29])")), ( - stbt, - timedelta(hours=2), - STBox("STBOX T([2019-09-01 02:00:00,2019-09-02 02:00:00])"), + stbt, + timedelta(hours=2), + STBox("STBOX T([2019-09-01 02:00:00,2019-09-02 02:00:00])"), ), ( - stbt, - timedelta(hours=-2), - STBox("STBOX T([2019-08-31 22:00:00,2019-09-01 22:00:00])"), + stbt, + timedelta(hours=-2), + STBox("STBOX T([2019-08-31 22:00:00,2019-09-01 22:00:00])"), ), ], ids=["positive days", "negative days", "positive hours", "negative hours"], @@ -752,9 +779,9 @@ def test_shift_time(self, stbox, delta, expected): [ (stbt, timedelta(days=4), STBox("STBOX T([2019-09-01,2019-09-05])")), ( - stbt, - timedelta(hours=2), - STBox("STBOX T([2019-09-01,2019-09-01 02:00:00])"), + stbt, + timedelta(hours=2), + STBox("STBOX T([2019-09-01,2019-09-01 02:00:00])"), ), ], ids=["positive days", "positive hours"], @@ -771,31 +798,29 @@ def test_shift_scale_time(self): "stbox, expected", [ ( - STBox( - "STBOX X((1.123456789,1.123456789),(2.123456789,2.123456789))"), - STBox("STBOX X((1.12,1.12),(2.12,2.12))"), + STBox("STBOX X((1.123456789,1.123456789),(2.123456789,2.123456789))"), + STBox("STBOX X((1.12,1.12),(2.12,2.12))"), ), ( - STBox( - "STBOX Z((1.123456789,1.123456789,1.123456789),(2.123456789,2.123456789,2.123456789))" - ), - STBox("STBOX Z((1.12,1.12,1.12),(2.12,2.12,2.12))"), + STBox( + "STBOX Z((1.123456789,1.123456789,1.123456789),(2.123456789,2.123456789,2.123456789))" + ), + STBox("STBOX Z((1.12,1.12,1.12),(2.12,2.12,2.12))"), ), ( - STBox( - "STBOX XT(((1.123456789,1.123456789),(2.123456789,2.123456789)),[2019-09-01, 2019-09-02])" - ), - STBox( - "STBOX XT(((1.12,1.12),(2.12,2.12)),[2019-09-01, 2019-09-03])"), + STBox( + "STBOX XT(((1.123456789,1.123456789),(2.123456789,2.123456789)),[2019-09-01, 2019-09-02])" + ), + STBox("STBOX XT(((1.12,1.12),(2.12,2.12)),[2019-09-01, 2019-09-03])"), ), ( - STBox( - "STBOX ZT(((1.123456789,1.123456789,1.123456789),(2.123456789,2.123456789,2.123456789))," - "[2019-09-01, 2019-09-02])" - ), - STBox( - "STBOX ZT(((1.12,1.12,1.12),(2.12,2.12,2.12)),[2019-09-01, 2019-09-02])" - ), + STBox( + "STBOX ZT(((1.123456789,1.123456789,1.123456789),(2.123456789,2.123456789,2.123456789))," + "[2019-09-01, 2019-09-02])" + ), + STBox( + "STBOX ZT(((1.12,1.12,1.12),(2.12,2.12,2.12)),[2019-09-01, 2019-09-02])" + ), ), ], ids=["STBox X", "STBox Z", "STBox XT", "STBox ZT"], @@ -823,9 +848,9 @@ class TestSTBoxTopologicalFunctions(TestSTBox): (stbxt, STBox("STBOX XT(((1,1),(3,3)),[2019-09-01,2019-09-03])"), False), (stbxt, STBox("STBOX XT(((2,2),(3,3)),[2019-09-02,2019-09-03])"), True), ( - stbzt, - STBox("STBOX ZT(((1,1,1),(3,3,3)),[2019-09-01,2019-09-03])"), - False, + stbzt, + STBox("STBOX ZT(((1,1,1),(3,3,3)),[2019-09-01,2019-09-03])"), + False, ), (stbzt, STBox("STBOX ZT(((2,2,2),(3,3,3)),[2019-09-01,2019-09-03])"), True), ], @@ -857,9 +882,9 @@ def test_is_adjacent(self, stbox, argument, expected): (stbxt, STBox("STBOX XT(((2,2),(3,3)),[2019-09-02,2019-09-03])"), False), (stbxt, STBox("STBOX XT(((1,1),(3,3)),[2019-09-01,2019-09-03])"), True), ( - stbzt, - STBox("STBOX ZT(((2,2,2),(3,3,3)),[2019-09-01,2019-09-03])"), - False, + stbzt, + STBox("STBOX ZT(((2,2,2),(3,3,3)),[2019-09-01,2019-09-03])"), + False, ), (stbzt, STBox("STBOX ZT(((1,1,1),(3,3,3)),[2019-09-01,2019-09-03])"), True), ], @@ -892,9 +917,9 @@ def test_is_contained_in_contains(self, stbox, argument, expected): (stbxt, STBox("STBOX XT(((3,3),(3,3)),[2019-09-02,2019-09-03])"), False), (stbxt, STBox("STBOX XT(((1,1),(3,3)),[2019-09-01,2019-09-03])"), True), ( - stbzt, - STBox("STBOX ZT(((3,3,3),(3,3,3)),[2019-09-01,2019-09-03])"), - False, + stbzt, + STBox("STBOX ZT(((3,3,3),(3,3,3)),[2019-09-01,2019-09-03])"), + False, ), (stbzt, STBox("STBOX ZT(((1,1,1),(3,3,3)),[2019-09-01,2019-09-03])"), True), ], @@ -962,9 +987,9 @@ class TestSTBoxPositionFunctions(TestSTBox): (stbxt, STBox("STBOX XT(((1,1),(3,3)),[2019-09-01,2019-09-03])"), False), (stbxt, STBox("STBOX XT(((3,3),(4,4)),[2019-09-02,2019-09-03])"), True), ( - stbzt, - STBox("STBOX ZT(((1,1,1),(3,3,3)),[2019-09-01,2019-09-03])"), - False, + stbzt, + STBox("STBOX ZT(((1,1,1),(3,3,3)),[2019-09-01,2019-09-03])"), + False, ), (stbzt, STBox("STBOX ZT(((3,3,3),(4,4,4)),[2019-09-01,2019-09-03])"), True), ], @@ -995,9 +1020,9 @@ def test_is_left_right(self, stbox, argument, expected): (stbxt, STBox("STBOX XT(((1,1),(1,1)),[2019-09-01,2019-09-03])"), False), (stbxt, STBox("STBOX XT(((3,3),(4,4)),[2019-09-02,2019-09-03])"), True), ( - stbzt, - STBox("STBOX ZT(((1,1,1),(1,1,1)),[2019-09-01,2019-09-03])"), - False, + stbzt, + STBox("STBOX ZT(((1,1,1),(1,1,1)),[2019-09-01,2019-09-03])"), + False, ), (stbzt, STBox("STBOX ZT(((3,3,3),(4,4,4)),[2019-09-01,2019-09-03])"), True), ], @@ -1026,9 +1051,9 @@ def test_is_over_or_left(self, stbox, argument, expected): (stbxt, STBox("STBOX XT(((0,0),(1,1)),[2019-09-01,2019-09-03])"), False), (stbxt, STBox("STBOX XT(((3,3),(4,4)),[2019-09-02,2019-09-03])"), True), ( - stbzt, - STBox("STBOX ZT(((0,0,0),(1,1,1)),[2019-09-01,2019-09-03])"), - False, + stbzt, + STBox("STBOX ZT(((0,0,0),(1,1,1)),[2019-09-01,2019-09-03])"), + False, ), (stbzt, STBox("STBOX ZT(((3,3,3),(4,4,4)),[2019-09-01,2019-09-03])"), True), ], @@ -1053,9 +1078,9 @@ def test_is_over_or_right(self, stbox, argument, expected): (stbz, STBox("STBOX Z((1,1,1),(1,1,1))"), False), (stbz, STBox("STBOX Z((3,3,3),(4,4,4))"), True), ( - stbzt, - STBox("STBOX ZT(((1,1,1),(1,1,1)),[2019-09-01,2019-09-03])"), - False, + stbzt, + STBox("STBOX ZT(((1,1,1),(1,1,1)),[2019-09-01,2019-09-03])"), + False, ), (stbzt, STBox("STBOX ZT(((3,3,3),(4,4,4)),[2019-09-01,2019-09-03])"), True), ], @@ -1070,9 +1095,9 @@ def test_is_over_or_front(self, stbox, argument, expected): (stbz, STBox("STBOX Z((2,2,2),(2,2,2))"), False), (stbz, STBox("STBOX Z((1,1,1),(2,2,2))"), True), ( - stbzt, - STBox("STBOX ZT(((2,2,2),(2,2,2)),[2019-09-01,2019-09-03])"), - False, + stbzt, + STBox("STBOX ZT(((2,2,2),(2,2,2)),[2019-09-01,2019-09-03])"), + False, ), (stbzt, STBox("STBOX ZT(((1,1,1),(2,2,2)),[2019-09-01,2019-09-03])"), True), ], @@ -1089,9 +1114,9 @@ def test_is_over_or_behind(self, stbox, argument, expected): (stbxt, STBox("STBOX XT(((1,1),(3,3)),[2019-09-01,2019-09-03])"), False), (stbxt, STBox("STBOX XT(((3,3),(4,4)),[2019-09-03,2019-09-03])"), True), ( - stbzt, - STBox("STBOX ZT(((1,1,1),(3,3,3)),[2019-09-01,2019-09-03])"), - False, + stbzt, + STBox("STBOX ZT(((1,1,1),(3,3,3)),[2019-09-01,2019-09-03])"), + False, ), (stbzt, STBox("STBOX ZT(((3,3,3),(4,4,4)),[2019-09-03,2019-09-03])"), True), ], @@ -1116,9 +1141,9 @@ def test_is_before_after(self, stbox, argument, expected): (stbxt, STBox("STBOX XT(((1,1),(3,3)),[2019-09-01,2019-09-01])"), False), (stbxt, STBox("STBOX XT(((3,3),(4,4)),[2019-09-03,2019-09-03])"), True), ( - stbzt, - STBox("STBOX ZT(((1,1,1),(3,3,3)),[2019-09-01,2019-09-01])"), - False, + stbzt, + STBox("STBOX ZT(((1,1,1),(3,3,3)),[2019-09-01,2019-09-01])"), + False, ), (stbzt, STBox("STBOX ZT(((3,3,3),(4,4,4)),[2019-09-03,2019-09-03])"), True), ], @@ -1142,9 +1167,9 @@ def test_is_over_or_before(self, stbox, argument, expected): (stbxt, STBox("STBOX XT(((1,1),(3,3)),[2019-09-02,2019-09-03])"), False), (stbxt, STBox("STBOX XT(((3,3),(4,4)),[2019-09-01,2019-09-03])"), True), ( - stbzt, - STBox("STBOX ZT(((1,1,1),(3,3,3)),[2019-09-02,2019-09-03])"), - False, + stbzt, + STBox("STBOX ZT(((1,1,1),(3,3,3)),[2019-09-02,2019-09-03])"), + False, ), (stbzt, STBox("STBOX ZT(((3,3,3),(4,4,4)),[2019-09-01,2019-09-03])"), True), ], @@ -1195,9 +1220,9 @@ def test_in(self, stbox1, argument): (stbt1, stbt2, STBox("STBOX T([2019-09-01,2019-09-03])")), (stbxt1, stbxt2, STBox("STBOX XT(((1,1),(3,3)),[2019-09-01,2019-09-03])")), ( - stbzt1, - stbzt2, - STBox("STBOX ZT(((1,1,1),(3,3,3)),[2019-09-01,2019-09-03])"), + stbzt1, + stbzt2, + STBox("STBOX ZT(((1,1,1),(3,3,3)),[2019-09-01,2019-09-03])"), ), ], ids=["STBox X", "STBox Z", "STBox T", "STBox XT", "STBox ZT"], @@ -1214,9 +1239,9 @@ def test_union(self, stbox1, stbox2, expected): (stbt1, stbt2, STBox("STBOX T([2019-09-02,2019-09-02])")), (stbxt1, stbxt2, STBox("STBOX XT(((2,2),(2,2)),[2019-09-02,2019-09-02])")), ( - stbzt1, - stbzt2, - STBox("STBOX ZT(((2,2,2),(2,2,2)),[2019-09-02,2019-09-02])"), + stbzt1, + stbzt2, + STBox("STBOX ZT(((2,2,2),(2,2,2)),[2019-09-02,2019-09-02])"), ), ], ids=["STBox X", "STBox Z", "STBox T", "STBox XT", "STBox ZT"], @@ -1240,9 +1265,9 @@ class TestSTBoxDistanceFunctions(TestSTBox): (stbz, STBox("STBOX Z((3,3,3),(3,3,3))"), math.sqrt(3)), (stbxt, STBox("STBOX XT(((1,1),(3,3)),[2019-09-01,2019-09-03])"), 0), ( - stbzt, - STBox("STBOX ZT(((3,3,3),(3,3,3)),[2019-09-01,2019-09-03])"), - math.sqrt(3), + stbzt, + STBox("STBOX ZT(((3,3,3),(3,3,3)),[2019-09-01,2019-09-03])"), + math.sqrt(3), ), ], ids=["STBox X", "STBox Z", "STBox XT", "STBox ZT"], diff --git a/tests/main/tgeogpoint_test.py b/tests/main/tgeogpoint_test.py index 1818c74e..d7cadfcd 100644 --- a/tests/main/tgeogpoint_test.py +++ b/tests/main/tgeogpoint_test.py @@ -1812,10 +1812,7 @@ def test_round(self, temporal, expected): [ ( TGeogPointInst("Point(42.84979 42.38153)@2019-09-01"), - TGeogPointInst( - "SRID=8426;" - "Point(42.84979 42.38153)@2019-09-01" - ), + TGeogPointInst("SRID=8426;" "Point(42.84979 42.38153)@2019-09-01"), ), ( TGeogPointSeq( diff --git a/tests/main/tgeompoint_test.py b/tests/main/tgeompoint_test.py index 68952793..5019ceb0 100644 --- a/tests/main/tgeompoint_test.py +++ b/tests/main/tgeompoint_test.py @@ -1908,39 +1908,40 @@ def test_expand(self, temporal, expected): "temporal, expected", [ ( - TGeomPointInst("SRID=4326;Point(2.05455 41.62840)@2019-09-01"), - TGeomPointInst( - "SRID=2062;Point(1077794.3091235077 796037.0089003219)@2019-09-01"), + TGeomPointInst("SRID=4326;Point(2.05455 41.62840)@2019-09-01"), + TGeomPointInst( + "SRID=2062;Point(1077794.3091235077 796037.0089003219)@2019-09-01" + ), ), ( - TGeomPointSeq( - "SRID=4326;{Point(2.05455 41.62840)@2019-09-01," - "Point(1.63164 41.41622)@2019-09-02}" - ), - TGeomPointSeq( - "SRID=2062;{Point(1077794.3091235077 796037.0089003219)@2019-09-01,Point(1044050.9767668848 770349.6009306419)@2019-09-02}" - ), + TGeomPointSeq( + "SRID=4326;{Point(2.05455 41.62840)@2019-09-01," + "Point(1.63164 41.41622)@2019-09-02}" + ), + TGeomPointSeq( + "SRID=2062;{Point(1077794.3091235077 796037.0089003219)@2019-09-01,Point(1044050.9767668848 770349.6009306419)@2019-09-02}" + ), ), ( - TGeomPointSeq( - "SRID=4326;[Point(2.05455 41.62840)@2019-09-01," - "Point(1.63164 41.41622)@2019-09-02]" - ), - TGeomPointSeq( - "SRID=2062;[Point(1077794.3091235077 796037.0089003219)@2019-09-01,Point(1044050.9767668848 770349.6009306419)@2019-09-02]" - ), + TGeomPointSeq( + "SRID=4326;[Point(2.05455 41.62840)@2019-09-01," + "Point(1.63164 41.41622)@2019-09-02]" + ), + TGeomPointSeq( + "SRID=2062;[Point(1077794.3091235077 796037.0089003219)@2019-09-01,Point(1044050.9767668848 770349.6009306419)@2019-09-02]" + ), ), ( - TGeomPointSeqSet( - "SRID=4326;{[Point(2.05455 41.62840)@2019-09-01," - "Point(1.63164 41.41622)@2019-09-02]," - "[Point(1.74064 41.48158)@2019-09-03," - "Point(2.54287 41.70331)@2019-09-05]}" - ), - TGeomPointSeq( - "SRID=2062;{[Point(1077794.3091235077 796037.0089003219)@2019-09-01,Point(1044050.9767668848 770349.6009306419)@2019-09-02]," - "[Point(1052698.1755408798 778137.4310070301)@2019-09-03,Point(1117783.9536644723 807058.9808454381)@2019-09-05]}" - ), + TGeomPointSeqSet( + "SRID=4326;{[Point(2.05455 41.62840)@2019-09-01," + "Point(1.63164 41.41622)@2019-09-02]," + "[Point(1.74064 41.48158)@2019-09-03," + "Point(2.54287 41.70331)@2019-09-05]}" + ), + TGeomPointSeq( + "SRID=2062;{[Point(1077794.3091235077 796037.0089003219)@2019-09-01,Point(1044050.9767668848 770349.6009306419)@2019-09-02]," + "[Point(1052698.1755408798 778137.4310070301)@2019-09-03,Point(1117783.9536644723 807058.9808454381)@2019-09-05]}" + ), ), ], ids=["Instant", "Discrete Sequence", "Sequence", "SequenceSet"], @@ -1952,6 +1953,7 @@ def test_transform(self, temporal, expected): assert transformed.round(5) == expected.round(5) assert transformed.srid() == srid + class TestTGeomPointModifications(TestTGeomPoint): tpi = TGeomPointInst("Point(1 1)@2019-09-01") tpds = TGeomPointSeq("{Point(1 1)@2019-09-01, Point(2 2)@2019-09-02}")