@@ -173,6 +173,27 @@ def test_box_histogram(float_series):
173173 )
174174
175175
176+ def test_add_traces_from_other_figure ():
177+ labels = ["Investing" , "Liquid" , "Real Estate" , "Retirement" ]
178+ values = [324643.4435821581 , 112238.37140194925 , 2710711.06 , 604360.2864262027 ]
179+
180+ changes_section = FigureResampler (
181+ make_subplots (
182+ rows = 1 ,
183+ cols = 2 ,
184+ subplot_titles = ("Asset Allocation" , "Changes in last 12 hours" ),
185+ specs = [[{"type" : "pie" }, {"type" : "xy" }]],
186+ )
187+ )
188+
189+ # First create a pie chart Figure
190+ pie_total = go .Figure (data = [go .Pie (labels = labels , values = values )])
191+
192+ # Add the pie chart traces to the changes_section figure
193+ for trace in pie_total .data :
194+ changes_section .add_trace (trace , row = 1 , col = 1 )
195+
196+
176197def test_cat_box_histogram (float_series ):
177198 # Create a categorical series, with mostly a's, but a few sparse b's and c's
178199 cats_list = np .array (list ("aaaaaaaaaa" * 1000 ))
@@ -620,7 +641,9 @@ def test_stop_server_inline_persistent():
620641 fr .add_trace (go .Scattergl (name = "test" ), hf_x = x , hf_y = y )
621642 fr .update_layout (height = 900 )
622643 fr .stop_server ()
623- proc = multiprocessing .Process (target = fr .show_dash , kwargs = dict (mode = "inline_persistent" ))
644+ proc = multiprocessing .Process (
645+ target = fr .show_dash , kwargs = dict (mode = "inline_persistent" )
646+ )
624647 proc .start ()
625648
626649 time .sleep (3 )
@@ -640,8 +663,11 @@ def test_manual_jupyterdashpersistentinline():
640663
641664 # no need to start the app (we just need the FigureResampler object)
642665
643- from plotly_resampler .figure_resampler .figure_resampler import JupyterDashPersistentInlineOutput
666+ from plotly_resampler .figure_resampler .figure_resampler import (
667+ JupyterDashPersistentInlineOutput ,
668+ )
644669 import dash
670+
645671 app = JupyterDashPersistentInlineOutput ("manual_app" )
646672 assert hasattr (app , "_uid" )
647673
@@ -650,17 +676,15 @@ def test_manual_jupyterdashpersistentinline():
650676 # JupyterDashPersistentInline its _display_inline_output method (to create the img)
651677 app .layout = dash .html .Div (
652678 [
653- dash .dcc .Graph (
654- id = "resample-figure" , figure = fr
655- ),
679+ dash .dcc .Graph (id = "resample-figure" , figure = fr ),
656680 # no need to add traceupdater for this dummy app
657681 ]
658682 )
659683
660684 # call the method (as it would normally be called)
661- app ._display_in_jupyter (f"" , port = "" , mode = "inline" , width = ' 100%' , height = 500 )
685+ app ._display_in_jupyter (f"" , port = "" , mode = "inline" , width = " 100%" , height = 500 )
662686 # call with a different mode (as it normally never would be called)
663- app ._display_in_jupyter (f"" , port = "" , mode = "external" , width = ' 100%' , height = 500 )
687+ app ._display_in_jupyter (f"" , port = "" , mode = "external" , width = " 100%" , height = 500 )
664688
665689
666690def test_stop_server_external ():
@@ -977,7 +1001,9 @@ def test_fr_object_bool_data(bool_series):
9771001
9781002
9791003def test_fr_object_binary_data ():
980- binary_series = np .array ([0 , 1 ]* 20 , dtype = "int32" ) # as this is << max_n_samples -> limit_to_view
1004+ binary_series = np .array (
1005+ [0 , 1 ] * 20 , dtype = "int32"
1006+ ) # as this is << max_n_samples -> limit_to_view
9811007
9821008 # First try with the original non-object binary series
9831009 fig = FigureResampler ()
@@ -994,7 +1020,9 @@ def test_fr_object_binary_data():
9941020 fig .add_trace ({"name" : "s0" }, hf_y = binary_series_o , limit_to_view = True )
9951021 assert binary_series_o .dtype == object
9961022 assert len (fig .hf_data ) == 1
997- assert (fig .hf_data [0 ]["y" ].dtype == "int32" ) or (fig .hf_data [0 ]["y" ].dtype == "int64" )
1023+ assert (fig .hf_data [0 ]["y" ].dtype == "int32" ) or (
1024+ fig .hf_data [0 ]["y" ].dtype == "int64"
1025+ )
9981026 assert str (fig .data [0 ]["y" ].dtype ).startswith ("int" )
9991027 assert np .all (fig .data [0 ]["y" ] == binary_series )
10001028
@@ -1015,7 +1043,7 @@ def test_fr_copy_grid():
10151043 assert fr ._grid_ref == f ._grid_ref
10161044 assert fr ._grid_str is not None
10171045 assert fr ._grid_str == f ._grid_str
1018-
1046+
10191047 ## go.FigureWidget
10201048 fw = go .FigureWidget (f )
10211049 assert fw ._grid_ref is not None
@@ -1040,6 +1068,7 @@ def test_fr_copy_grid():
10401068
10411069 ## FigureWidgetResampler
10421070 from plotly_resampler import FigureWidgetResampler
1071+
10431072 fwr = FigureWidgetResampler (f )
10441073 assert fwr ._grid_ref is not None
10451074 assert fwr ._grid_str is not None
0 commit comments