@@ -50,9 +50,17 @@ def test_replaceDataWithNaN():
50
50
```
51
51
"""
52
52
id_replace = np .array ([0 , 16 ])
53
- data = np .stack ([np .linspace (1 , 100 , 20 )] * 2 , axis = 1 )
53
+ xData = np .linspace (1 , 100 , 20 )
54
+ yData = xData .copy ()
55
+ data = np .stack ([xData , yData ], axis = 1 )
56
+
57
+ with plt .rc_context (rc = RC_PARAMS ):
58
+ fig , ax = plt .subplots (1 , 1 , figsize = (5 , 5 ))
59
+ l , = ax .plot (xData , yData )
54
60
55
- newdata = cleanfigure .replaceDataWithNaN (data , id_replace )
61
+ cleanfigure .replaceDataWithNaN (l , id_replace )
62
+
63
+ newdata = np .stack (l .get_data (), axis = 1 )
56
64
assert newdata .shape == data .shape
57
65
assert np .any (np .isnan (newdata ))
58
66
@@ -73,9 +81,16 @@ def test_removeData():
73
81
```
74
82
"""
75
83
id_remove = np .array ([1 , 2 , 3 , 17 , 18 , 19 ])
76
- data = np .stack ([np .linspace (1 , 100 , 20 )] * 2 , axis = 1 )
84
+ xData = np .linspace (1 , 100 , 20 )
85
+ yData = xData .copy ()
86
+ data = np .stack ([xData , yData ], axis = 1 )
77
87
78
- newdata = cleanfigure .removeData (data , id_remove )
88
+ with plt .rc_context (rc = RC_PARAMS ):
89
+ fig , ax = plt .subplots (1 , 1 , figsize = (5 , 5 ))
90
+ l , = ax .plot (xData , yData )
91
+
92
+ cleanfigure .removeData (l , id_remove )
93
+ newdata = np .stack (l .get_data (), axis = 1 )
79
94
assert newdata .shape == (14 , 2 )
80
95
81
96
@@ -96,10 +111,17 @@ def test_removeNaNs():
96
111
"""
97
112
id_replace = np .array ([0 , 16 ])
98
113
id_remove = np .array ([1 , 2 , 3 , 17 , 18 , 19 ])
99
- data = np .stack ([np .linspace (1 , 100 , 20 )] * 2 , axis = 1 )
100
- newdata = cleanfigure .replaceDataWithNaN (data , id_replace )
101
- newdata = cleanfigure .removeData (newdata , id_remove )
102
- newdata = cleanfigure .removeNaNs (newdata )
114
+ xData = np .linspace (1 , 100 , 20 )
115
+ yData = xData .copy ()
116
+ data = np .stack ([xData , yData ], axis = 1 )
117
+
118
+ with plt .rc_context (rc = RC_PARAMS ):
119
+ fig , ax = plt .subplots (1 , 1 , figsize = (5 , 5 ))
120
+ l , = ax .plot (xData , yData )
121
+ cleanfigure .replaceDataWithNaN (l , id_replace )
122
+ cleanfigure .removeData (l , id_remove )
123
+ cleanfigure .removeNaNs (l )
124
+ newdata = np .stack (l .get_data (), axis = 1 )
103
125
assert not np .any (np .isnan (newdata ))
104
126
assert newdata .shape == (12 , 2 )
105
127
0 commit comments