@@ -129,6 +129,42 @@ def test_select_annotations(self):
129129 self .assert_selected ("annotations" , [0 , 1 ], row = "paper" , col = "paper" )
130130 self .assert_selected ("annotations" , [4 ], secondary_y = True )
131131
132+ def test_select_shapes (self ):
133+ (
134+ self .fig .add_shape (opacity = 0.1 , fillcolor = "red" )
135+ .add_shape (opacity = 0.2 , fillcolor = "blue" )
136+ .add_shape (opacity = 0.3 , fillcolor = "red" , row = 1 , col = 1 )
137+ .add_shape (opacity = 0.4 , row = 1 , col = 2 )
138+ .add_shape (opacity = 0.5 , row = 1 , col = 2 , secondary_y = True )
139+ .add_shape (opacity = 0.6 , fillcolor = "blue" , row = 2 , col = 1 )
140+ )
141+
142+ # Test selections
143+ self .assert_selected ("shapes" , [0 , 1 , 2 , 3 , 4 , 5 ])
144+ self .assert_selected ("shapes" , [0 , 2 ], selector = dict (fillcolor = "red" ))
145+ self .assert_selected ("shapes" , [2 , 3 , 4 ], row = 1 )
146+ self .assert_selected ("shapes" , [2 ], selector = dict (fillcolor = "red" ), row = 1 )
147+ self .assert_selected ("shapes" , [0 , 1 ], row = "paper" , col = "paper" )
148+ self .assert_selected ("shapes" , [4 ], secondary_y = True )
149+
150+ def test_select_images (self ):
151+ (
152+ self .fig .add_image (opacity = 0.1 , source = "red" )
153+ .add_image (opacity = 0.2 , source = "blue" )
154+ .add_image (opacity = 0.3 , source = "red" , row = 1 , col = 1 )
155+ .add_image (opacity = 0.4 , row = 1 , col = 2 )
156+ .add_image (opacity = 0.5 , row = 1 , col = 2 , secondary_y = True )
157+ .add_image (opacity = 0.6 , source = "blue" , row = 2 , col = 1 )
158+ )
159+
160+ # Test selections
161+ self .assert_selected ("images" , [0 , 1 , 2 , 3 , 4 , 5 ])
162+ self .assert_selected ("images" , [0 , 2 ], selector = dict (source = "red" ))
163+ self .assert_selected ("images" , [2 , 3 , 4 ], row = 1 )
164+ self .assert_selected ("images" , [2 ], selector = dict (source = "red" ), row = 1 )
165+ self .assert_selected ("images" , [0 , 1 ], row = "paper" , col = "paper" )
166+ self .assert_selected ("images" , [4 ], secondary_y = True )
167+
132168 def test_update_annotations (self ):
133169 (
134170 self .fig .add_annotation (text = "A1" , arrowcolor = "red" )
@@ -153,3 +189,39 @@ def test_update_annotations(self):
153189 self .assert_update (
154190 "annotations" , [4 ], patch = dict (showarrow = False ), secondary_y = True
155191 )
192+
193+ def test_update_shapes (self ):
194+ (
195+ self .fig .add_shape (opacity = 0.1 , fillcolor = "red" )
196+ .add_shape (opacity = 0.2 , fillcolor = "blue" )
197+ .add_shape (opacity = 0.3 , fillcolor = "red" , row = 1 , col = 1 )
198+ .add_shape (opacity = 0.4 , row = 1 , col = 2 )
199+ .add_shape (opacity = 0.5 , row = 1 , col = 2 , secondary_y = True )
200+ .add_shape (opacity = 0.6 , fillcolor = "blue" , row = 2 , col = 1 )
201+ )
202+
203+ self .assert_update ("shapes" , [0 , 1 , 2 , 3 , 4 , 5 ], patch = dict (opacity = 0 ))
204+ self .assert_update (
205+ "shapes" , [1 , 5 ], patch = dict (opacity = 0 ), selector = dict (fillcolor = "blue" )
206+ )
207+ self .assert_update ("shapes" , [2 , 3 , 4 ], patch = dict (opacity = 0 ), row = 1 )
208+ self .assert_update ("shapes" , [2 , 5 ], patch = dict (opacity = 0 ), col = 1 )
209+ self .assert_update ("shapes" , [4 ], patch = dict (opacity = 0 ), secondary_y = True )
210+
211+ def test_update_images (self ):
212+ (
213+ self .fig .add_image (opacity = 0.1 , source = "red" )
214+ .add_image (opacity = 0.2 , source = "blue" )
215+ .add_image (opacity = 0.3 , source = "red" , row = 1 , col = 1 )
216+ .add_image (opacity = 0.4 , row = 1 , col = 2 )
217+ .add_image (opacity = 0.5 , row = 1 , col = 2 , secondary_y = True )
218+ .add_image (opacity = 0.6 , source = "blue" , row = 2 , col = 1 )
219+ )
220+
221+ self .assert_update ("images" , [0 , 1 , 2 , 3 , 4 , 5 ], patch = dict (opacity = 0 ))
222+ self .assert_update (
223+ "images" , [1 , 5 ], patch = dict (opacity = 0 ), selector = dict (source = "blue" )
224+ )
225+ self .assert_update ("images" , [2 , 3 , 4 ], patch = dict (opacity = 0 ), row = 1 )
226+ self .assert_update ("images" , [2 , 5 ], patch = dict (opacity = 0 ), col = 1 )
227+ self .assert_update ("images" , [4 ], patch = dict (opacity = 0 ), secondary_y = True )
0 commit comments