15
15
from matplotlib .path import Path
16
16
17
17
18
- @pytest .fixture
19
- def set_simplify_and_threshold ():
20
- plt .rcParams ['path.simplify' ] = True
21
- plt .rcParams ['path.simplify_threshold' ] = 0.1111111111111111
22
-
23
-
24
18
@image_comparison (baseline_images = ['clipping' ], remove_text = True )
25
- def test_clipping (set_simplify_and_threshold ):
19
+ def test_clipping ():
26
20
t = np .arange (0.0 , 2.0 , 0.01 )
27
21
s = np .sin (2 * np .pi * t )
28
22
@@ -32,7 +26,7 @@ def test_clipping(set_simplify_and_threshold):
32
26
33
27
34
28
@image_comparison (baseline_images = ['overflow' ], remove_text = True )
35
- def test_overflow (set_simplify_and_threshold ):
29
+ def test_overflow ():
36
30
x = np .array ([1.0 , 2.0 , 3.0 , 2.0e5 ])
37
31
y = np .arange (len (x ))
38
32
@@ -42,7 +36,7 @@ def test_overflow(set_simplify_and_threshold):
42
36
43
37
44
38
@image_comparison (baseline_images = ['clipping_diamond' ], remove_text = True )
45
- def test_diamond (set_simplify_and_threshold ):
39
+ def test_diamond ():
46
40
x = np .array ([0.0 , 1.0 , 0.0 , - 1.0 , 0.0 ])
47
41
y = np .array ([1.0 , 0.0 , - 1.0 , 0.0 , 1.0 ])
48
42
@@ -52,7 +46,7 @@ def test_diamond(set_simplify_and_threshold):
52
46
ax .set_ylim (ymin = - 0.6 , ymax = 0.6 )
53
47
54
48
55
- def test_noise (set_simplify_and_threshold ):
49
+ def test_noise ():
56
50
np .random .seed (0 )
57
51
x = np .random .uniform (size = (50000 ,)) * 50
58
52
@@ -64,10 +58,10 @@ def test_noise(set_simplify_and_threshold):
64
58
path = transform .transform_path (path )
65
59
simplified = path .cleaned (simplify = True )
66
60
67
- assert simplified .vertices .size == 25888
61
+ assert simplified .vertices .size == 25510
68
62
69
63
70
- def test_antiparallel_simplification (set_simplify_and_threshold ):
64
+ def test_antiparallel_simplification ():
71
65
def _get_simplified (x ,y ):
72
66
fig , ax = plt .subplots ()
73
67
p1 = ax .plot (x , y )
@@ -141,7 +135,7 @@ def _get_simplified(x,y):
141
135
[ 1. , 0.5 ]],
142
136
simplified .vertices [:- 2 , :])
143
137
144
- def test_sine_plus_noise (set_simplify_and_threshold ):
138
+ def test_sine_plus_noise ():
145
139
np .random .seed (0 )
146
140
x = (np .sin (np .linspace (0 , np .pi * 2.0 , 50000 )) +
147
141
np .random .uniform (size = (50000 ,)) * 0.01 )
@@ -154,11 +148,11 @@ def test_sine_plus_noise(set_simplify_and_threshold):
154
148
path = transform .transform_path (path )
155
149
simplified = path .cleaned (simplify = True )
156
150
157
- assert simplified .vertices .size == 25598
151
+ assert simplified .vertices .size == 25238
158
152
159
153
160
154
@image_comparison (baseline_images = ['simplify_curve' ], remove_text = True )
161
- def test_simplify_curve (set_simplify_and_threshold ):
155
+ def test_simplify_curve ():
162
156
pp1 = patches .PathPatch (
163
157
Path ([(0 , 0 ), (1 , 0 ), (1 , 1 ), (np .nan , 1 ), (0 , 0 ), (2 , 0 ), (2 , 2 ),
164
158
(0 , 0 )],
@@ -173,15 +167,15 @@ def test_simplify_curve(set_simplify_and_threshold):
173
167
174
168
175
169
@image_comparison (baseline_images = ['hatch_simplify' ], remove_text = True )
176
- def test_hatch (set_simplify_and_threshold ):
170
+ def test_hatch ():
177
171
fig , ax = plt .subplots ()
178
172
ax .add_patch (plt .Rectangle ((0 , 0 ), 1 , 1 , fill = False , hatch = "/" ))
179
173
ax .set_xlim ((0.45 , 0.55 ))
180
174
ax .set_ylim ((0.45 , 0.55 ))
181
175
182
176
183
177
@image_comparison (baseline_images = ['fft_peaks' ], remove_text = True )
184
- def test_fft_peaks (set_simplify_and_threshold ):
178
+ def test_fft_peaks ():
185
179
fig , ax = plt .subplots ()
186
180
t = np .arange (65536 )
187
181
p1 = ax .plot (abs (np .fft .fft (np .sin (2 * np .pi * .01 * t )* np .blackman (len (t )))))
@@ -191,10 +185,10 @@ def test_fft_peaks(set_simplify_and_threshold):
191
185
path = transform .transform_path (path )
192
186
simplified = path .cleaned (simplify = True )
193
187
194
- assert simplified .vertices .size == 38
188
+ assert simplified .vertices .size == 36
195
189
196
190
197
- def test_start_with_moveto (set_simplify_and_threshold ):
191
+ def test_start_with_moveto ():
198
192
# Should be entirely clipped away to a single MOVETO
199
193
data = b"""
200
194
ZwAAAAku+v9UAQAA+Tj6/z8CAADpQ/r/KAMAANlO+v8QBAAAyVn6//UEAAC6ZPr/2gUAAKpv+v+8
@@ -249,7 +243,7 @@ def test_throw_rendering_complexity_exceeded():
249
243
250
244
251
245
@image_comparison (baseline_images = ['clipper_edge' ], remove_text = True )
252
- def test_clipper (set_simplify_and_threshold ):
246
+ def test_clipper ():
253
247
dat = (0 , 1 , 0 , 2 , 0 , 3 , 0 , 4 , 0 , 5 )
254
248
fig = plt .figure (figsize = (2 , 1 ))
255
249
fig .subplots_adjust (left = 0 , bottom = 0 , wspace = 0 , hspace = 0 )
@@ -265,7 +259,7 @@ def test_clipper(set_simplify_and_threshold):
265
259
266
260
267
261
@image_comparison (baseline_images = ['para_equal_perp' ], remove_text = True )
268
- def test_para_equal_perp (set_simplify_and_threshold ):
262
+ def test_para_equal_perp ():
269
263
x = np .array ([0 , 1 , 2 , 1 , 0 , - 1 , 0 , 1 ] + [1 ] * 128 )
270
264
y = np .array ([1 , 1 , 2 , 1 , 0 , - 1 , 0 , 0 ] + [0 ] * 128 )
271
265
@@ -275,7 +269,7 @@ def test_para_equal_perp(set_simplify_and_threshold):
275
269
276
270
277
271
@image_comparison (baseline_images = ['clipping_with_nans' ])
278
- def test_clipping_with_nans (set_simplify_and_threshold ):
272
+ def test_clipping_with_nans ():
279
273
x = np .linspace (0 , 3.14 * 2 , 3000 )
280
274
y = np .sin (x )
281
275
x [::100 ] = np .nan
@@ -285,7 +279,7 @@ def test_clipping_with_nans(set_simplify_and_threshold):
285
279
ax .set_ylim (- 0.25 , 0.25 )
286
280
287
281
288
- def test_clipping_full (set_simplify_and_threshold ):
282
+ def test_clipping_full ():
289
283
p = Path ([[1e30 , 1e30 ]] * 5 )
290
284
simplified = list (p .iter_segments (clip = [0 , 0 , 100 , 100 ]))
291
285
assert simplified == []
0 commit comments