Skip to content

Shift and scale dates by whole days, refusing a part below a day - #115

Merged
estebanzimanyi merged 1 commit into
MobilityDB:masterfrom
estebanzimanyi:fix/date-shift-whole-days
Nov 14, 2026
Merged

estebanzimanyi merged 1 commit into
MobilityDB:masterfrom
estebanzimanyi:fix/date-shift-whole-days

Conversation

@estebanzimanyi

Copy link
Copy Markdown
Member

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.

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.
@estebanzimanyi
estebanzimanyi merged commit 5b67ccb into MobilityDB:master Nov 14, 2026
10 of 16 checks passed
@estebanzimanyi
estebanzimanyi deleted the fix/date-shift-whole-days branch November 14, 2026 08:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant