Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inconsistent handling of (start, end, value) in DatetimeRangeSlider and DatetimeRangePicker widget #7272

Open
rhambach opened this issue Sep 13, 2024 · 0 comments

Comments

@rhambach
Copy link

rhambach commented Sep 13, 2024

ALL software version info

Software Version Info
panel  1.4.5
param 2.1.1

Description of expected behavior and the observed behavior

  • DatetimeRangePicker should allow changing start and end without raising out-of-bound exception
  • value of DatetimeRange* widgets is always between start and end parameter or an Exception is raised
  • same behavior of DatetimeRangeSlider and DatetimeRangePicker widget on this issue

Complete, minimal, self-contained example code that reproduces the issue

import panel as pn
import datetime as dt
dtmin = dt.datetime(1000, 1, 1)
dtlow = dt.datetime(2000, 1, 1)
dtmax = dt.datetime(3000, 1, 1)

# increasing (start, end) and set value=(start, end) SHOULD WORK !
sel_dtrange = pn.widgets.DatetimeRangeSlider(start=dtmin, end=dtlow, value=(dtmin, dtlow))
sel_dtrange.param.update(start=dtmin, end=dtmax, value=(dtmin, dtmax))  # OK

sel_dtrange = pn.widgets.DatetimeRangePicker(start=dtmin, end=dtlow, value=(dtmin, dtlow))
sel_dtrange.param.update(start=dtmin, end=dtmax, value=(dtmin, dtmax))  # ERROR
sel_dtrange.param.update(start=dtmin, end=dtmax)  # increasing (start, end) without setting value works

Stack traceback and/or browser JavaScript console output

---> [12] sel_dtrange.param.update(start=dtmin, end=dtmax, value=(dtmin, dtmax))  # ERROR

ValueError: DateRange parameter 'DatetimeRangePicker.value' upper bound must be in range [1000-01-01 00:00:00, 2000-01-01 00:00:00], not 3000-01-01 00:00:00.

Additional Info

On the contrary, the DatetimeRangeSlider does not raise an exception although value is out of bounds, which might also not be expected by the user.

import panel as pn
import datetime as dt
dtmin = dt.datetime(1000, 1, 1)
dtlow = dt.datetime(2000, 1, 1)
dtmax = dt.datetime(3000, 1, 1)

# reducing (start, end) without correcting out-of-range value SHOULD FAIL !
sel_dtrange = pn.widgets.DatetimeRangeSlider(start=dtmin, end=dtmax, value=(dtmin, dtmax))
sel_dtrange.param.update(start=dtmin, end=dtlow)   # ERROR as value is out of bounds and should raise


sel_dtrange = pn.widgets.DatetimeRangePicker(start=dtmin, end=dtmax, value=(dtmin, dtmax))
#sel_dtrange.param.update(start=dtmin, end=dtlow)   # OK, fails as value is out of bounds
sel_dtrange.param.update(start=dtmin, end=dtlow, value=(dtmin, dtlow))  # OK, setting value to reduced bounds works
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

No branches or pull requests

1 participant