From: Debian Science Team Date: Sun, 22 Jan 2023 11:54:30 +0000 (+0000) Subject: Don't fail plot tests on rounding error X-Git-Tag: archive/raspbian/1.5.3+dfsg-2+rpi1~1^2~2 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=c7c57d754020d316e4a1771dea9b6ccb767468ba;p=pandas.git Don't fail plot tests on rounding error Author: Rebecca N. Palmer Bug-Debian: https://bugs.debian.org/1029251 Forwarded: no Gbp-Pq: Name 1029251_ignore_rounding_error.patch --- diff --git a/pandas/tests/plotting/frame/test_frame_subplots.py b/pandas/tests/plotting/frame/test_frame_subplots.py index 47d91c79..387c0b2e 100644 --- a/pandas/tests/plotting/frame/test_frame_subplots.py +++ b/pandas/tests/plotting/frame/test_frame_subplots.py @@ -4,6 +4,7 @@ import string import warnings import numpy as np +from numpy.testing import assert_array_almost_equal_nulp import pytest import pandas.util._test_decorators as td @@ -378,7 +379,7 @@ class TestDataFramePlotsSubplots(TestPlotBase): # no subplots df = DataFrame({"A": [3] * 5, "B": list(range(1, 6))}, index=range(5)) ax = df.plot.bar(grid=True, log=True) - tm.assert_numpy_array_equal(ax.yaxis.get_ticklocs(), expected) + assert_array_almost_equal_nulp(ax.yaxis.get_ticklocs(), expected, 4) def test_bar_log_subplots(self): expected = np.array([0.1, 1.0, 10.0, 100.0, 1000.0, 1e4]) @@ -387,8 +388,8 @@ class TestDataFramePlotsSubplots(TestPlotBase): log=True, subplots=True ) - tm.assert_numpy_array_equal(ax[0].yaxis.get_ticklocs(), expected) - tm.assert_numpy_array_equal(ax[1].yaxis.get_ticklocs(), expected) + assert_array_almost_equal_nulp(ax[0].yaxis.get_ticklocs(), expected, 4) + assert_array_almost_equal_nulp(ax[1].yaxis.get_ticklocs(), expected, 4) def test_boxplot_subplots_return_type(self, hist_df): df = hist_df diff --git a/pandas/tests/plotting/test_series.py b/pandas/tests/plotting/test_series.py index 46b2b827..4ba3a80b 100644 --- a/pandas/tests/plotting/test_series.py +++ b/pandas/tests/plotting/test_series.py @@ -3,6 +3,7 @@ from datetime import datetime from itertools import chain import numpy as np +from numpy.testing import assert_array_almost_equal_nulp import pytest import pandas.util._test_decorators as td @@ -249,12 +250,12 @@ class TestSeriesPlots(TestPlotBase): _, ax = self.plt.subplots() ax = Series([200, 500]).plot.bar(log=True, ax=ax) - tm.assert_numpy_array_equal(ax.yaxis.get_ticklocs(), expected) + assert_array_almost_equal_nulp(ax.yaxis.get_ticklocs(), expected, 4) tm.close() _, ax = self.plt.subplots() ax = Series([200, 500]).plot.barh(log=True, ax=ax) - tm.assert_numpy_array_equal(ax.xaxis.get_ticklocs(), expected) + assert_array_almost_equal_nulp(ax.xaxis.get_ticklocs(), expected, 4) tm.close() # GH 9905 @@ -267,7 +268,7 @@ class TestSeriesPlots(TestPlotBase): res = ax.get_ylim() tm.assert_almost_equal(res[0], ymin) tm.assert_almost_equal(res[1], ymax) - tm.assert_numpy_array_equal(ax.yaxis.get_ticklocs(), expected) + assert_array_almost_equal_nulp(ax.yaxis.get_ticklocs(), expected, 4) tm.close() _, ax = self.plt.subplots() @@ -275,7 +276,7 @@ class TestSeriesPlots(TestPlotBase): res = ax.get_xlim() tm.assert_almost_equal(res[0], ymin) tm.assert_almost_equal(res[1], ymax) - tm.assert_numpy_array_equal(ax.xaxis.get_ticklocs(), expected) + assert_array_almost_equal_nulp(ax.xaxis.get_ticklocs(), expected, 4) def test_bar_ignore_index(self): df = Series([1, 2, 3, 4], index=["a", "b", "c", "d"])