Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a5cc230

Browse files
QuLogictimhoffm
andauthored
TST: account for flakiness with Numpy v1 (matplotlib#30950)
* TST: account for flakiness with Numpy v1 * Expand comment with instructions Co-authored-by: Tim Hoffmann <[email protected]> --------- Co-authored-by: Tim Hoffmann <[email protected]>
2 parents bc2a816 + df1351c commit a5cc230

3 files changed

Lines changed: 11 additions & 3 deletions

File tree

lib/matplotlib/tests/test_axes.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1576,6 +1576,9 @@ def test_pcolor_log_scale(fig_test, fig_ref):
15761576
when using pcolor.
15771577
"""
15781578
x = np.linspace(0, 1, 11)
1579+
# Ensuring second x value always falls slightly above 0.1 prevents flakiness with
1580+
# numpy v1 #30882. This can be removed once we require numpy >= 2.
1581+
x[1] += 0.00001
15791582
y = np.linspace(1, 2, 5)
15801583
X, Y = np.meshgrid(x, y)
15811584
C = X[:-1, :-1] + Y[:-1, :-1]

lib/matplotlib/tests/test_ticker.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from packaging.version import parse as parse_version
77

88
import numpy as np
9-
from numpy.testing import assert_almost_equal, assert_array_equal
9+
from numpy.testing import assert_almost_equal, assert_array_equal, assert_allclose
1010
import pytest
1111

1212
import matplotlib as mpl
@@ -1935,7 +1935,10 @@ def test_bad_locator_subs(sub):
19351935
@mpl.style.context('default')
19361936
def test_small_range_loglocator(numticks, lims, ticks):
19371937
ll = mticker.LogLocator(numticks=numticks)
1938-
assert_array_equal(ll.tick_values(*lims), ticks)
1938+
if parse_version(np.version.version).major < 2:
1939+
assert_allclose(ll.tick_values(*lims), ticks, rtol=2e-16)
1940+
else:
1941+
assert_array_equal(ll.tick_values(*lims), ticks)
19391942

19401943

19411944
@mpl.style.context('default')

lib/mpl_toolkits/mplot3d/tests/test_axes3d.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import platform
44
import sys
55

6+
from packaging.version import parse as parse_version
67
import pytest
78

89
from mpl_toolkits.mplot3d import Axes3D, axes3d, proj3d, art3d
@@ -181,7 +182,8 @@ def test_bar3d_shaded():
181182
fig.canvas.draw()
182183

183184

184-
@mpl3d_image_comparison(['bar3d_notshaded.png'], style='mpl20')
185+
@mpl3d_image_comparison(['bar3d_notshaded.png'], style='mpl20',
186+
tol=0.01 if parse_version(np.version.version).major < 2 else 0)
185187
def test_bar3d_notshaded():
186188
fig = plt.figure()
187189
ax = fig.add_subplot(projection='3d')

0 commit comments

Comments
 (0)