Repository navigation
Shift and scale dates by whole days, refusing a part below a day - #115
Merged
estebanzimanyi merged 1 commit intoNov 14, 2026
Merged
Conversation
DateSet, DateSpan and DateSpanSet shift_scale, and the shift and scale that call it, read a timedelta through the new whole_days of pymeos/collections/time/timecollection.py: the number of days of a timedelta of whole days, an int as given, a ValueError for a timedelta with a part below a day. They state a shift or a width to MEOS whenever one is given, so shift(0) answers a value equal to self. Why. MEOS shifts and scales dates by a whole number of days (dateset_shift_scale, datespan_shift_scale, datespanset_shift_scale take an int), as SQL shift(datespan, integer) and PostgreSQL date + integer do, and has no cast of an interval to a number of days; a binding reaches that int through its host type alone, and a timedelta holding hours cannot state it (doc/specs/meos-bindings-algebra.md of MobilityDB, section 5). TT-6 of the plan of the time types, MobilityDB #3666. Measured. Against the libmeos of MobilityDB master f4d735a8d9, PyMEOS master 622ccd1 answers, for each of DateSet, DateSpan and DateSpanSet: shift(timedelta(hours=12)) raises the MEOS error "At least one of the arguments shift or width must be given", the half day floored to zero; shift(timedelta(hours=-1)) moves every date one day earlier, timedelta(hours=-1).days being -1; shift(timedelta(days=1, hours=23)) moves by one day; scale(timedelta(hours=36)) scales to a width of one day; shift(0) and shift(timedelta(0)) raise that MEOS error, a shift of zero being sent as no shift. This change answers a ValueError for each timedelta with a part below a day and a value equal to self for a shift of zero days. Witness. tests/collections/time/dateset_test.py and datespanset_test.py gain test_shift_zero and test_shift_scale_below_a_day, which fail on master (10 cases) and pass here; the suite passes but for the 4 cases of test_oo_codegen_coverage.py, which read the catalog CI stages and fail the same way on master without it; ruff check and ruff format pass.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
DateSet, DateSpan and DateSpanSet shift_scale, and the shift and scale that call it, read a timedelta through the new whole_days of pymeos/collections/time/timecollection.py: the number of days of a timedelta of whole days, an int as given, a ValueError for a timedelta with a part below a day. They state a shift or a width to MEOS whenever one is given, so shift(0) answers a value equal to self.
Why. MEOS shifts and scales dates by a whole number of days (dateset_shift_scale, datespan_shift_scale, datespanset_shift_scale take an int), as SQL shift(datespan, integer) and PostgreSQL date + integer do, and has no cast of an interval to a number of days; a binding reaches that int through its host type alone, and a timedelta holding hours cannot state it (doc/specs/meos-bindings-algebra.md of MobilityDB, section 5). TT-6 of the plan of the time types, MobilityDB #3666.
Measured. Against the libmeos of MobilityDB master f4d735a8d9, PyMEOS master 622ccd1 answers, for each of DateSet, DateSpan and DateSpanSet: shift(timedelta(hours=12)) raises the MEOS error "At least one of the arguments shift or width must be given", the half day floored to zero; shift(timedelta(hours=-1)) moves every date one day earlier, timedelta(hours=-1).days being -1; shift(timedelta(days=1, hours=23)) moves by one day; scale(timedelta(hours=36)) scales to a width of one day; shift(0) and shift(timedelta(0)) raise that MEOS error, a shift of zero being sent as no shift. This change answers a ValueError for each timedelta with a part below a day and a value equal to self for a shift of zero days.
Witness. tests/collections/time/dateset_test.py and datespanset_test.py gain test_shift_zero and test_shift_scale_below_a_day, which fail on master (10 cases) and pass here; the suite passes but for the 4 cases of test_oo_codegen_coverage.py, which read the catalog CI stages and fail the same way on master without it; ruff check and ruff format pass.