@@ -758,7 +758,7 @@ def test_compare_tz_with_fixed_offset():
758758 # related: https://github.com/predict-idlab/plotly-resampler/issues/305
759759 fig = FigureResampler ()
760760
761- x = pd .date_range ("2024-04-01T00:00:00" , "2025-01-01T00:00:00" , freq = "H " )
761+ x = pd .date_range ("2024-04-01T00:00:00" , "2025-01-01T00:00:00" , freq = "h " )
762762 x = x .tz_localize ("Asia/Taipei" )
763763 y = np .random .randn (len (x ))
764764
@@ -779,7 +779,7 @@ def test_compare_tz_with_fixed_offset_2():
779779 # related: https://github.com/predict-idlab/plotly-resampler/issues/305
780780 fig = FigureResampler ()
781781
782- x = pd .date_range ("2024-04-01T00:00:00" , "2025-01-01T00:00:00" , freq = "H " )
782+ x = pd .date_range ("2024-04-01T00:00:00" , "2025-01-01T00:00:00" , freq = "h " )
783783 x = x .tz_localize ("UTC" )
784784 x = x .tz_convert ("Canada/Pacific" )
785785 y = np .random .randn (len (x ))
@@ -801,6 +801,27 @@ def test_compare_tz_with_fixed_offset_2():
801801 fig .construct_update_data_patch (relayout_data )
802802
803803
804+ def test_relayout_tz_DST ():
805+ # related: https://github.com/predict-idlab/plotly-resampler/issues/305
806+ fig = FigureResampler ()
807+
808+ x = pd .date_range (
809+ "2024-09-27 17:00:00" , "2024-12-11 16:00:00" , tz = "US/Pacific" , freq = "1h"
810+ )
811+ y = np .random .randn (len (x ))
812+ fig .add_trace (
813+ go .Scattergl (x = x , y = y , name = "demo" , mode = "lines+markers" ),
814+ max_n_samples = int (len (x ) * 0.2 ),
815+ )
816+
817+ relayout_data = {
818+ "xaxis.range[0]" : "2024-09-27T17:00:00-07:00" ,
819+ "xaxis.range[1]" : "2024-12-12T15:59:00-08:00" ,
820+ }
821+
822+ fig .construct_update_data_patch (relayout_data )
823+
824+
804825def test_datetime_hf_x_no_index ():
805826 df = pd .DataFrame (
806827 {"timestamp" : pd .date_range ("2020-01-01" , "2020-01-02" , freq = "1s" )}
@@ -836,8 +857,8 @@ def test_multiple_timezones_in_single_x_index__datetimes_and_timestamps():
836857 # TODO: can be improved with pytest parametrize
837858 y = np .arange (20 )
838859
839- index1 = pd .date_range ("2018-01-01" , periods = 10 , freq = "H " , tz = "US/Eastern" )
840- index2 = pd .date_range ("2018-01-02" , periods = 10 , freq = "H " , tz = "Asia/Dubai" )
860+ index1 = pd .date_range ("2018-01-01" , periods = 10 , freq = "h " , tz = "US/Eastern" )
861+ index2 = pd .date_range ("2018-01-02" , periods = 10 , freq = "h " , tz = "Asia/Dubai" )
841862 index_timestamps = index1 .append (index2 )
842863 assert all (isinstance (x , pd .Timestamp ) for x in index_timestamps )
843864 index1_datetimes = pd .Index ([x .to_pydatetime () for x in index1 ])
@@ -1158,7 +1179,7 @@ def test_multiple_tz_no_tz_series_slicing():
11581179
11591180 # Now the assumption cannot be made that s has the same time-zone as the
11601181 # timestamps -> AssertionError will be raised.
1161- with pytest .raises (AssertionError ):
1182+ with pytest .raises (( TypeError , AssertionError ) ):
11621183 hf_data_dict = construct_hf_data_dict (s .tz_localize (None ).index , s .values )
11631184 PlotlyAggregatorParser .get_start_end_indices (
11641185 hf_data_dict , hf_data_dict ["axis_type" ], t_start , t_stop
0 commit comments