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

Skip to content

Commit c0cc7a6

Browse files
authored
Merge pull request #25827 from meeseeksmachine/auto-backport-of-pr-25813-on-v3.7.x
Backport PR #25813 on branch v3.7.x ([TST] Adjust tests to be more tolerant to floating point math operations being imprecise)
2 parents 98443b5 + 6738dcf commit c0cc7a6

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed

lib/matplotlib/tests/test_axes.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4433,7 +4433,8 @@ def test_mollweide_forward_inverse_closure():
44334433

44344434
# set up 1-degree grid in longitude, latitude
44354435
lon = np.linspace(-np.pi, np.pi, 360)
4436-
lat = np.linspace(-np.pi / 2.0, np.pi / 2.0, 180)
4436+
# The poles are degenerate and thus sensitive to floating point precision errors
4437+
lat = np.linspace(-np.pi / 2.0, np.pi / 2.0, 180)[1:-1]
44374438
lon, lat = np.meshgrid(lon, lat)
44384439
ll = np.vstack((lon.flatten(), lat.flatten())).T
44394440

lib/matplotlib/tests/test_polar.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -425,13 +425,13 @@ def test_axvline_axvspan_do_not_modify_rlims():
425425
def test_cursor_precision():
426426
ax = plt.subplot(projection="polar")
427427
# Higher radii correspond to higher theta-precisions.
428-
assert ax.format_coord(0, 0) == "θ=0π (0°), r=0.000"
428+
assert ax.format_coord(0, 0.005) == "θ=0.0π (0°), r=0.005"
429429
assert ax.format_coord(0, .1) == "θ=0.00π (0°), r=0.100"
430430
assert ax.format_coord(0, 1) == "θ=0.000π (0.0°), r=1.000"
431-
assert ax.format_coord(1, 0) == "θ=0.3π (57°), r=0.000"
431+
assert ax.format_coord(1, 0.005) == "θ=0.3π (57°), r=0.005"
432432
assert ax.format_coord(1, .1) == "θ=0.32π (57°), r=0.100"
433433
assert ax.format_coord(1, 1) == "θ=0.318π (57.3°), r=1.000"
434-
assert ax.format_coord(2, 0) == "θ=0.6π (115°), r=0.000"
434+
assert ax.format_coord(2, 0.005) == "θ=0.6π (115°), r=0.005"
435435
assert ax.format_coord(2, .1) == "θ=0.64π (115°), r=0.100"
436436
assert ax.format_coord(2, 1) == "θ=0.637π (114.6°), r=1.000"
437437

lib/mpl_toolkits/mplot3d/tests/test_axes3d.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -181,9 +181,9 @@ def test_bar3d_lightsource():
181181

182182
# Testing that the custom 90° lightsource produces different shading on
183183
# the top facecolors compared to the default, and that those colors are
184-
# precisely the colors from the colormap, due to the illumination parallel
185-
# to the z-axis.
186-
np.testing.assert_array_equal(color, collection._facecolor3d[1::6])
184+
# precisely (within floating point rounding errors of 4 ULP) the colors
185+
# from the colormap, due to the illumination parallel to the z-axis.
186+
np.testing.assert_array_max_ulp(color, collection._facecolor3d[1::6], 4)
187187

188188

189189
@mpl3d_image_comparison(['contour3d.png'])

0 commit comments

Comments
 (0)