@@ -45,9 +45,21 @@ def test_pruneOutsideBox():
45
45
(l ,) = ax .plot (x , y )
46
46
ax .set_ylim ([20 , 80 ])
47
47
ax .set_xlim ([20 , 80 ])
48
- cleanfigure ._prune_outside_box (fig , ax , l )
49
- assert l .get_xdata ().shape == (14 ,)
50
- plt .close ("all" )
48
+ axhandle = ax
49
+ linehandle = l
50
+ fighandle = fig
51
+ xData , yData = cleanfigure ._get_visual_data (axhandle , linehandle )
52
+ visual_data = cleanfigure ._stack_data_2D (xData , yData )
53
+ data = cleanfigure ._get_data (linehandle )
54
+ xLim , yLim = cleanfigure ._get_visual_limits (fighandle , axhandle )
55
+ is3D = cleanfigure ._lineIs3D (linehandle )
56
+ hasLines = cleanfigure ._line_has_lines (linehandle )
57
+
58
+ data = cleanfigure ._prune_outside_box (
59
+ xLim , yLim , data , visual_data , is3D , hasLines
60
+ )
61
+ assert data .shape == (14 , 2 )
62
+
51
63
52
64
53
65
def test_replaceDataWithNaN ():
@@ -71,16 +83,9 @@ def test_replaceDataWithNaN():
71
83
yData = xData .copy ()
72
84
data = np .stack ([xData , yData ], axis = 1 )
73
85
74
- with plt .rc_context (rc = RC_PARAMS ):
75
- fig , ax = plt .subplots (1 , 1 , figsize = (5 , 5 ))
76
- (l ,) = ax .plot (xData , yData )
77
-
78
- cleanfigure ._replace_data_with_NaN (l , id_replace )
79
-
80
- newdata = np .stack (l .get_data (), axis = 1 )
86
+ newdata = cleanfigure ._replace_data_with_NaN (data , id_replace , False )
81
87
assert newdata .shape == data .shape
82
88
assert np .any (np .isnan (newdata ))
83
- plt .close ("all" )
84
89
85
90
86
91
def test_removeData ():
@@ -102,15 +107,10 @@ def test_removeData():
102
107
id_remove = np .array ([1 , 2 , 3 , 17 , 18 , 19 ])
103
108
xData = np .linspace (1 , 100 , 20 )
104
109
yData = xData .copy ()
110
+ data = np .stack ([xData , yData ], axis = 1 )
105
111
106
- with plt .rc_context (rc = RC_PARAMS ):
107
- fig , ax = plt .subplots (1 , 1 , figsize = (5 , 5 ))
108
- (l ,) = ax .plot (xData , yData )
109
-
110
- cleanfigure ._remove_data (l , id_remove )
111
- newdata = np .stack (l .get_data (), axis = 1 )
112
+ newdata = cleanfigure ._remove_data (data , id_remove , False )
112
113
assert newdata .shape == (14 , 2 )
113
- plt .close ("all" )
114
114
115
115
116
116
def test_removeNaNs ():
0 commit comments