@@ -50,7 +50,7 @@ def on_color_indices_changed(color_indices):
5050 assert scatter .color_indices .shape == (size ,)
5151
5252 # Test scatter colors
53- colors = scatter ._scatter .get_facecolors ()
53+ colors = scatter ._mpl_artists [ 'scatter' ] .get_facecolors ()
5454 assert np .all (colors [0 ] == scatter .overlay_colormap (0 ))
5555 assert np .all (colors [50 ] == scatter .overlay_colormap (2 ))
5656
@@ -69,27 +69,27 @@ def on_color_indices_changed(color_indices):
6969 # Test size property
7070 scatter .size = 5.0
7171 assert scatter .size == 5.0
72- sizes = scatter ._scatter .get_sizes ()
72+ sizes = scatter ._mpl_artists [ 'scatter' ] .get_sizes ()
7373 assert np .all (sizes == 5.0 )
7474
7575 scatter .size = np .linspace (1 , 10 , size )
7676 assert np .all (scatter .size == np .linspace (1 , 10 , size ))
77- sizes = scatter ._scatter .get_sizes ()
77+ sizes = scatter ._mpl_artists [ 'scatter' ] .get_sizes ()
7878 assert np .all (sizes == np .linspace (1 , 10 , size ))
7979
8080 # Test size reset when new data is set
8181 scatter .data = np .random .rand (size // 2 , 2 )
8282 assert np .all (scatter .size == 50.0 ) # that's the default
83- sizes = scatter ._scatter .get_sizes ()
83+ sizes = scatter ._mpl_artists [ 'scatter' ] .get_sizes ()
8484 assert np .all (sizes == 50.0 )
8585
8686 # test alpha
8787 scatter .alpha = 0.5
88- assert np .all (scatter ._scatter .get_alpha () == 0.5 )
88+ assert np .all (scatter ._mpl_artists [ 'scatter' ] .get_alpha () == 0.5 )
8989
9090 # test alpha reset when new data is set
9191 scatter .data = np .random .rand (size , 2 )
92- assert np .all (scatter ._scatter .get_alpha () == 1.0 )
92+ assert np .all (scatter ._mpl_artists [ 'scatter' ] .get_alpha () == 1.0 )
9393
9494 # Test changing overlay_colormap
9595 assert scatter .overlay_colormap .name == "cat10_modified"
@@ -98,7 +98,7 @@ def on_color_indices_changed(color_indices):
9898
9999 # Test scatter color indices after continuous overlay_colormap
100100 scatter .color_indices = np .linspace (0 , 1 , size )
101- colors = scatter ._scatter .get_facecolors ()
101+ colors = scatter ._mpl_artists [ 'scatter' ] .get_facecolors ()
102102 assert np .all (colors [0 ] == plt .cm .viridis (0 ))
103103
104104 # Test scatter color_normalization_method
@@ -181,7 +181,7 @@ def on_color_indices_changed(color_indices):
181181 assert histogram .cmin == 0
182182
183183 # Test overlay colors
184- overlay_array = histogram ._overlay_histogram_image .get_array ()
184+ overlay_array = histogram ._mpl_artists [ 'overlay_histogram_image' ] .get_array ()
185185 assert overlay_array .shape == (bins , bins , 4 )
186186 # indices where overlay_array is not zero
187187 indices = np .where (overlay_array [..., - 1 ] != 0 )
@@ -229,7 +229,7 @@ def on_color_indices_changed(color_indices):
229229
230230 # Don't draw overlay histogram if color_indices are nan
231231 histogram .color_indices = np .nan
232- assert histogram . _overlay_histogram_image is None
232+ assert 'overlay_histogram_image' not in histogram . _mpl_artists . keys ()
233233
234234
235235# Test calculate_statistic_histogram_method for different statistics
@@ -245,43 +245,3 @@ def on_color_indices_changed(color_indices):
245245 [[0.0 , np .nan , np .nan ], [np .nan , 3.0 , np .nan ], [np .nan , np .nan , 7.5 ]]
246246 ),
247247]
248-
249-
250- @pytest .mark .parametrize (
251- "statistic,expected_array" ,
252- zip (statistics , expected_results ),
253- ids = statistics ,
254- )
255- def test_calculate_statistic_histogram_method (statistic , expected_array ):
256- input_xy_data = np .array (
257- [
258- [1 , 2 ],
259- [3 , 4 ],
260- [3 , 5 ],
261- [4 , 5 ],
262- [5 , 6 ],
263- [6 , 7 ],
264- ]
265- )
266- bins = 3
267- input_features = np .array ([0 , 1 , 2 , 6 , 7 , 8 ])
268-
269- expected_histogram_array = np .array (
270- [[1.0 , 0.0 , 0.0 ], [0.0 , 3.0 , 0.0 ], [0.0 , 0.0 , 2.0 ]]
271- )
272-
273- histogram = Histogram2D (data = input_xy_data , bins = bins )
274- histogram_array , x_edges , y_edges = histogram .histogram
275- assert np .all (histogram_array == expected_histogram_array )
276- # Get the bin index for each x value ( -1 to start from index 0 and clip to handle edge cases)
277- x_bin_indices = (
278- np .digitize (input_xy_data [:, 0 ], x_edges , right = False ) - 1
279- ).clip (0 , len (x_edges ) - 2 )
280- # Get the bin index for each y value ( -1 to start from index 0 and clip to handle edge cases)
281- y_bin_indices = (
282- np .digitize (input_xy_data [:, 1 ], y_edges , right = False ) - 1
283- ).clip (0 , len (y_edges ) - 2 )
284- result = histogram ._calculate_statistic_histogram (
285- x_bin_indices , y_bin_indices , input_features , statistic = statistic
286- )
287- assert np .array_equal (result , expected_array , equal_nan = True )
0 commit comments