Skip to content

Commit

Permalink
Add tests with NaN and Inf
Browse files Browse the repository at this point in the history
  • Loading branch information
t20100 committed Apr 5, 2024
1 parent 2603b25 commit 947bff2
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/silx/gui/plot/test/testPlotWidget.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
import numpy
import pytest

from packaging.version import Version

from silx.utils.testutils import ParametricTestCase
from silx.gui.utils.testutils import SignalListener
from silx.gui.utils.testutils import TestCaseQt
Expand Down Expand Up @@ -2062,14 +2064,18 @@ class TestSpecial_ExplicitMplBackend(TestSpecialBackend):
([(1, 2, 3), (3, 2, 1)], [(3, 2, 1), (1, 2, 3)]), # 2xN array
(-1, -1), # Negative values
((-1, 0, 1), (1, 0, -1)), # Flat array with negative values
(-numpy.inf, numpy.inf), # Infinity error
(numpy.nan, numpy.nan), # All NaN
((1, numpy.nan, 2), (numpy.nan, 3, 2)), # Some NaN
],
)
def testCurveErrors(qapp, plotWidget, xerror, yerror):
"""Test display of curves with different errors"""
item = plotWidget.addCurve(x=(1, 2, 3), y=(3, 2, 1), xerror=xerror, yerror=yerror)

assert numpy.array_equal(xerror, item.getXErrorData())
assert numpy.array_equal(yerror, item.getYErrorData())
if Version(numpy.version.version) >= Version("1.19.0"): # Use equal_nan argument
assert numpy.array_equal(xerror, item.getXErrorData(), equal_nan=True)
assert numpy.array_equal(yerror, item.getYErrorData(), equal_nan=True)

plotWidget.resetZoom()
qapp.processEvents()
Expand Down

0 comments on commit 947bff2

Please sign in to comment.