Skip to content

Commit

Permalink
Sync with MEOS
Browse files Browse the repository at this point in the history
  • Loading branch information
Diviloper committed Dec 29, 2023
1 parent bd976a5 commit e10ff46
Show file tree
Hide file tree
Showing 7 changed files with 2,233 additions and 246 deletions.
6 changes: 3 additions & 3 deletions pymeos/pymeos/boxes/tbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -666,9 +666,9 @@ def round(self, max_decimals: int = 0) -> TBox:
MEOS Functions:
tbox_round
"""
new_inner = tbox_copy(self._inner)
tbox_round(new_inner, max_decimals)
return TBox(_inner=new_inner)
if not self._is_float():
return TBox(_inner=tbox_copy(self._inner))
return TBox(_inner=tbox_round(self._inner, max_decimals))

# ------------------------- Set Operations --------------------------------
def union(self, other: TBox, strict: Optional[bool] = True) -> TBox:
Expand Down
12 changes: 6 additions & 6 deletions pymeos/pymeos/collections/time/tstzspanset.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,9 @@ def start_timestamp(self) -> datetime:
A :class:`datetime` instance
MEOS Functions:
tstzspanset_start_timestamp
tstzspanset_start_timestamptz
"""
return timestamptz_to_datetime(tstzspanset_start_timestamp(self._inner))
return timestamptz_to_datetime(tstzspanset_start_timestamptz(self._inner))

def end_timestamp(self) -> datetime:
"""
Expand All @@ -140,9 +140,9 @@ def end_timestamp(self) -> datetime:
A :class:`datetime` instance
MEOS Functions:
tstzspanset_end_timestamp
tstzspanset_end_timestamptz
"""
return timestamptz_to_datetime(tstzspanset_end_timestamp(self._inner))
return timestamptz_to_datetime(tstzspanset_end_timestamptz(self._inner))

def timestamp_n(self, n: int) -> datetime:
"""
Expand All @@ -151,11 +151,11 @@ def timestamp_n(self, n: int) -> datetime:
A :class:`datetime` instance
MEOS Functions:
spanset_timestamp_n
tstzspanset_timestamptz_n
"""
if n < 0 or n >= self.num_timestamps():
raise IndexError(f"Index {n} out of bounds")
return timestamptz_to_datetime(tstzspanset_timestamp_n(self._inner, n + 1))
return timestamptz_to_datetime(tstzspanset_timestamptz_n(self._inner, n + 1))

def timestamps(self) -> List[datetime]:
"""
Expand Down
10 changes: 5 additions & 5 deletions pymeos/pymeos/temporal/temporal.py
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,7 @@ def start_timestamp(self) -> datetime:
MEOS Functions:
temporal_start_timestamps
"""
return timestamptz_to_datetime(temporal_start_timestamp(self._inner))
return timestamptz_to_datetime(temporal_start_timestamptz(self._inner))

def end_timestamp(self) -> datetime:
"""
Expand All @@ -462,16 +462,16 @@ def end_timestamp(self) -> datetime:
MEOS Functions:
temporal_end_timestamps
"""
return timestamptz_to_datetime(temporal_end_timestamp(self._inner))
return timestamptz_to_datetime(temporal_end_timestamptz(self._inner))

def timestamp_n(self, n: int) -> datetime:
"""
Returns the n-th timestamp in `self`. (0-based)
MEOS Functions:
temporal_timestamp_n
temporal_timestamptz_n
"""
return timestamptz_to_datetime(temporal_timestamp_n(self._inner, n + 1))
return timestamptz_to_datetime(temporal_timestamptz_n(self._inner, n + 1))

def timestamps(self) -> List[datetime]:
"""
Expand Down Expand Up @@ -1251,7 +1251,7 @@ def time_split_n(self, n: int) -> List[TG]:
"""
if self.end_timestamp() == self.start_timestamp():
return [self]
st = temporal_start_timestamp(self._inner)
st = temporal_start_timestamptz(self._inner)
dt = timedelta_to_interval((self.end_timestamp() - self.start_timestamp()) / n)
fragments, times, count = temporal_time_split(self._inner, dt, st)
from ..factory import _TemporalFactory
Expand Down
6 changes: 3 additions & 3 deletions pymeos/tests/boxes/tbox_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -808,21 +808,21 @@ def test_shift_scale_time(self, tbox, delta, duration, expected):
TBox(
"TBOXFLOAT XT([1.123456789,2.123456789],[2019-09-01, 2019-09-02])"
),
TBox("TBOXFLOAT XT([1.12,2.12],[2019-09-01, 2019-09-03])"),
TBox("TBOXFLOAT XT([1.12,2.12],[2019-09-01, 2019-09-02])"),
),
(
TBox("TBOXINT X([1,2])"),
TBox("TBOXINT X([1,2])"),
),
(
TBox("TBOXINT XT([1,2],[2019-09-01, 2019-09-02])"),
TBox("TBOXINT XT([1,2],[2019-09-01, 2019-09-03])"),
TBox("TBOXINT XT([1,2],[2019-09-01, 2019-09-02])"),
),
],
ids=["TBoxFloat X", "TBoxFloat XT", "TBoxInt X", "TBoxInt XT"],
)
def test_round(self, tbox, expected):
assert tbox.round(max_decimals=2)
assert tbox.round(max_decimals=2) == expected


class TestTBoxTopologicalFunctions(TestTBox):
Expand Down
Loading

0 comments on commit e10ff46

Please sign in to comment.