-
-
Notifications
You must be signed in to change notification settings - Fork 72
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
[BUG] Error handling timezones #305
Comments
Can be fixed by |
But fix only works when there is no switch to DST. Timezone Canada/Pacific, for example, changes timezone upon switch to and from DST, so if the above code is run like
you get the error: Is there a reason not to use |
You can also try using the pytz library to handle timezone conversions and DST transitions. Here's an example: import pytz ...x = pd.date_range("2024-04-01T00:00:00", "2025-01-01T00:00:00", freq="H") ...relayout_data = { |
I tried to fix this behavior in #318 by catching the legacy
However, this introduces the possibly unwanted behavior, that different timezones with the same offset, are considered valid. (e.g. "Europe/Brussels" and "Europe/Amsterdam" are two different timezone objects / strings, but with the same offset -> so they are considered as equal.) This is also expressed in the following tests: plotly-resampler/tests/test_figure_resampler.py Lines 1051 to 1098 in 1f88adb
I would like to hear your opinion on this matter before continuing on this PR. |
@Jmbols @DHRUVCHARNE, any thoughts/remarks on my above comment? |
This is the behaviour I would expect. "Europe/Brussels" and "Europe/Amsterdam" are equivalent for all intents and purposes. The main issue I can see with that is if they have different dates when switching to and from DST, but presumably this would be caught by the offset check? |
Would it be easier if everything was converted to UTC first, then calculate, then at the last moment before returning a Patch, convert back to the original timezone? |
* fix: check if update_data contains update before batch_update * add test + avoid same error when verbose=True * 🧹 create _hf_data_container if correct trace type * 🙏 python 3.7 not supported on Apple Silicon * remove WIP * 🖊️ more verbose asserts * 🖊️ more verbose asserts * 🙏 more sleep time * 🙏 * 🙌 * 🤔 fix for [BUG] Error handling timezones #305 * 🙈 linting * 💨 Refactor timezone handling in PlotlyAggregatorParser * Update minmax operator image Signed-off-by: Emmanuel Ferdman <[email protected]> * Drop duplicate sentence * Feat/plotly6 (#338) * Parametrize test_utils.py on is_figure * 🔍 remove dtype parsing as orjon>3.10 supports float16 #118 * 💪 refactor: streamline JupyterDash integration and remove unused persistent inline logic * 💨 move construct_update_data_patch method into the FigureResampler class * 🐐 refactor: enhance test utilities and add support for Plotly>=6 data handling * 🙏 enhance serialization tests for plotly>6 * 📝 remove debug print statement and enhance type handling for hf_x * 🔒 update dependency versions in pyproject.toml to Support plotly 6 #334 * 🔍 drop python3.7 CI workflow and upgrade upload-artifact action * 🙏 fix pickling of figurewidget resampler * 🙏 fix tests * 💨 migration of code towards new upload artifact * 💪 enhance CI workflow to improve test result uploads and add retention settings * 🕳️ fix: ensure correct dtype handling for aggregated x indices in PlotlyAggregatorParser * ⬆️ chore: update dependency constraints for pandas and pyarrow in pyproject.toml * 🙈 fix linting * 🔍 fix: correct spelling in streamlit_app.py comments and update dash-extensions and pyarrow versions in requirements.txt * ⬆️ chore: update ipywidgets version constraint to allow for newer versions * 🚧 test: set random seed for reproducibility in test_wrap_aggregate * 🙈 chore: update ipywidgets version constraint for serialization support * 🙈 * 🔍 ci: conditionally skip tests on Python 3.12 for Ubuntu (as it keeps hanging in github actions) * 🔍 ci: exclude Python 3.12 on Ubuntu from test matrix to prevent hangs * 🖊️ review code * 🧹 cleanup comments --------- Co-authored-by: Maxim Ivanov <[email protected]> Co-authored-by: jeroen <[email protected]> * 🤔 fix for [BUG] Error handling timezones #305 * 🙈 linting * 💨 Refactor timezone handling in PlotlyAggregatorParser * 📌 bug: Fix timezone handling for DST in PlotlyAggregatorParser and update tests --------- Signed-off-by: Emmanuel Ferdman <[email protected]> Co-authored-by: jvdd <[email protected]> Co-authored-by: Jeroen Van Der Donckt <[email protected]> Co-authored-by: Emmanuel Ferdman <[email protected]> Co-authored-by: Maxim Ivanov <[email protected]>
Description
There is an error trying to construct an update patch when the x-axis are dates with a specified timezone.
The error is when trying to compare timezones. Pandas pd.to_datetime() by default will convert a timezone to a fixed off-set, whereas the timezone in the x-axis has a different format. The off-set is the same because the data is created based on the same timezone.
/.pyenv/versions/3.11.1/envs/clearview-dash-311/lib/python3.11/site-packages/plotly_resampler/aggregation/plotly_aggregator_parser.py", line 41, in to_same_tz
assert ts.tz.str() == reference_tz.str()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Reproducing the bug 🔍
This code snippet reproduces the bug
Environment information
The text was updated successfully, but these errors were encountered: