You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Panel Version 0.6.4, Jupyter Notebook with Python 3.6 running on MacOS Mojave
Using a pn.widgets.IntRangeSlider to select a month range, I wanted to display the name of the selected months on the title of the plot. I used python's calendar library (import calendar) to get the name via calendar.month_name[selected_month].
When the plot loads the first time, the calendar.month_name works correctly and displays the default widget values (in this case August & October). But when you move the slider to select other months, then calendar.month_name[...] crashes because it is no longer receiving an integer. I have to wrap the value from the widget in np.int() to force an integer, so instead of calendar.month_name[sel_months[0]], I need to write calendar.month_name[np.int(sel_months[0])]
In my view, the np.int function should not be necessary since you'd expect an IntRangeSlider to provide Integers as values.
Either way, the behaviour should be consistent. If you need to wrap the widget's values in np.int(), then it should also happen the first time the plot is loading with the default values. Because otherwise —as was my case— you assume that calendar.month_name[sel_months[0]] is working fine (since it's displaying names), and it takes you ages to discover that the problem is there.
Panel Version 0.6.4, Jupyter Notebook with Python 3.6 running on MacOS Mojave
Using a
pn.widgets.IntRangeSlider
to select a month range, I wanted to display the name of the selected months on the title of the plot. I used python's calendar library (import calendar
) to get the name viacalendar.month_name[selected_month]
.When the plot loads the first time, the
calendar.month_name
works correctly and displays the default widget values (in this case August & October). But when you move the slider to select other months, thencalendar.month_name[...]
crashes because it is no longer receiving an integer. I have to wrap the value from the widget innp.int()
to force an integer, so instead ofcalendar.month_name[sel_months[0]]
, I need to writecalendar.month_name[np.int(sel_months[0])]
In my view, the
np.int
function should not be necessary since you'd expect an IntRangeSlider to provide Integers as values.Either way, the behaviour should be consistent. If you need to wrap the widget's values in
np.int()
, then it should also happen the first time the plot is loading with the default values. Because otherwise —as was my case— you assume thatcalendar.month_name[sel_months[0]]
is working fine (since it's displaying names), and it takes you ages to discover that the problem is there.To reproduce the issue:
Thanks for this great libray! ^_^
The text was updated successfully, but these errors were encountered: