diff options
Diffstat (limited to 'silx/gui/plot/test')
-rw-r--r-- | silx/gui/plot/test/testCurvesROIWidget.py | 219 | ||||
-rw-r--r-- | silx/gui/plot/test/testMaskToolsWidget.py | 7 | ||||
-rw-r--r-- | silx/gui/plot/test/testPlotWidget.py | 61 | ||||
-rw-r--r-- | silx/gui/plot/test/testSaveAction.py | 20 | ||||
-rw-r--r-- | silx/gui/plot/test/testScatterMaskToolsWidget.py | 5 | ||||
-rw-r--r-- | silx/gui/plot/test/testStats.py | 284 | ||||
-rw-r--r-- | silx/gui/plot/test/testUtilsAxis.py | 49 |
7 files changed, 459 insertions, 186 deletions
diff --git a/silx/gui/plot/test/testCurvesROIWidget.py b/silx/gui/plot/test/testCurvesROIWidget.py index 0704779..5bcabd8 100644 --- a/silx/gui/plot/test/testCurvesROIWidget.py +++ b/silx/gui/plot/test/testCurvesROIWidget.py @@ -36,7 +36,7 @@ from collections import OrderedDict import numpy from silx.gui import qt from silx.test.utils import temp_dir -from silx.gui.utils.testutils import TestCaseQt +from silx.gui.utils.testutils import TestCaseQt, SignalListener from silx.gui.plot import PlotWindow, CurvesROIWidget @@ -52,7 +52,8 @@ class TestCurvesROIWidget(TestCaseQt): self.plot.show() self.qWaitForWindowExposed(self.plot) - self.widget = CurvesROIWidget.CurvesROIDockWidget(plot=self.plot, name='TEST') + self.widget = self.plot.getCurvesRoiDockWidget() + self.widget.show() self.qWaitForWindowExposed(self.widget) @@ -67,10 +68,6 @@ class TestCurvesROIWidget(TestCaseQt): super(TestCurvesROIWidget, self).tearDown() - def testEmptyPlot(self): - """Empty plot, display ROI widget""" - pass - def testWithCurves(self): """Plot with curves: test all ROI widget buttons""" for offset in range(2): @@ -80,13 +77,16 @@ class TestCurvesROIWidget(TestCaseQt): # Add two ROI self.mouseClick(self.widget.roiWidget.addButton, qt.Qt.LeftButton) + self.qWait(200) self.mouseClick(self.widget.roiWidget.addButton, qt.Qt.LeftButton) + self.qWait(200) # Change active curve self.plot.setActiveCurve(str(1)) # Delete a ROI self.mouseClick(self.widget.roiWidget.delButton, qt.Qt.LeftButton) + self.qWait(200) with temp_dir() as tmpDir: self.tmpFile = os.path.join(tmpDir, 'test.ini') @@ -94,30 +94,42 @@ class TestCurvesROIWidget(TestCaseQt): # Save ROIs self.widget.roiWidget.save(self.tmpFile) self.assertTrue(os.path.isfile(self.tmpFile)) + self.assertTrue(len(self.widget.getRois()) is 2) # Reset ROIs self.mouseClick(self.widget.roiWidget.resetButton, qt.Qt.LeftButton) + self.qWait(200) + rois = self.widget.getRois() + self.assertTrue(len(rois) is 1) + print(rois) + roiID = list(rois.keys())[0] + self.assertTrue(rois[roiID].getName() == 'ICR') # Load ROIs self.widget.roiWidget.load(self.tmpFile) + self.assertTrue(len(self.widget.getRois()) is 2) del self.tmpFile def testMiddleMarker(self): """Test with middle marker enabled""" - self.widget.roiWidget.setMiddleROIMarkerFlag(True) + self.widget.roiWidget.roiTable.setMiddleROIMarkerFlag(True) # Add a ROI self.mouseClick(self.widget.roiWidget.addButton, qt.Qt.LeftButton) - xleftMarker = self.plot._getMarker(legend='ROI min').getXPosition() - xMiddleMarker = self.plot._getMarker(legend='ROI middle').getXPosition() - xRightMarker = self.plot._getMarker(legend='ROI max').getXPosition() - self.assertAlmostEqual(xMiddleMarker, - xleftMarker + (xRightMarker - xleftMarker) / 2.) - - def testCalculation(self): + for roiID in self.widget.roiWidget.roiTable._markersHandler._roiMarkerHandlers: + handler = self.widget.roiWidget.roiTable._markersHandler._roiMarkerHandlers[roiID] + assert handler.getMarker('min') + xleftMarker = handler.getMarker('min').getXPosition() + xMiddleMarker = handler.getMarker('middle').getXPosition() + xRightMarker = handler.getMarker('max').getXPosition() + thValue = xleftMarker + (xRightMarker - xleftMarker) / 2. + self.assertAlmostEqual(xMiddleMarker, thValue) + + def testAreaCalculation(self): + """Test result of area calculation""" x = numpy.arange(100.) y = numpy.arange(100.) @@ -129,30 +141,60 @@ class TestCurvesROIWidget(TestCaseQt): self.plot.setActiveCurve("positive") # Add two ROIs - ddict = {} - ddict["positive"] = {"from": 10, "to": 20, "type":"X"} - ddict["negative"] = {"from": -20, "to": -10, "type":"X"} - self.widget.roiWidget.setRois(ddict) + roi_neg = CurvesROIWidget.ROI(name='negative', fromdata=-20, + todata=-10, type_='X') + roi_pos = CurvesROIWidget.ROI(name='positive', fromdata=10, + todata=20, type_='X') + + self.widget.roiWidget.setRois((roi_pos, roi_neg)) + + posCurve = self.plot.getCurve('positive') + negCurve = self.plot.getCurve('negative') + + self.assertEqual(roi_pos.computeRawAndNetArea(posCurve), + (numpy.trapz(y=[10, 20], x=[10, 20]), + 0.0)) + self.assertEqual(roi_pos.computeRawAndNetArea(negCurve), + (0.0, 0.0)) + self.assertEqual(roi_neg.computeRawAndNetArea(posCurve), + ((0.0), 0.0)) + self.assertEqual(roi_neg.computeRawAndNetArea(negCurve), + ((-150.0), 0.0)) + + def testCountsCalculation(self): + """Test result of count calculation""" + x = numpy.arange(100.) + y = numpy.arange(100.) - # And calculate the expected output - self.widget.calculateROIs() + # Add two curves + self.plot.addCurve(x, y, legend="positive") + self.plot.addCurve(-x, y, legend="negative") + + # Make sure there is an active curve and it is the positive one + self.plot.setActiveCurve("positive") - output = self.widget.roiWidget.getRois() - self.assertEqual(output["positive"]["rawcounts"], - y[ddict["positive"]["from"]:ddict["positive"]["to"]+1].sum(), - "Calculation failed on positive X coordinates") + # Add two ROIs + roi_neg = CurvesROIWidget.ROI(name='negative', fromdata=-20, + todata=-10, type_='X') + roi_pos = CurvesROIWidget.ROI(name='positive', fromdata=10, + todata=20, type_='X') + + self.widget.roiWidget.setRois((roi_pos, roi_neg)) - # Set the curve with negative X coordinates as active - self.plot.setActiveCurve("negative") + posCurve = self.plot.getCurve('positive') + negCurve = self.plot.getCurve('negative') - # the ROIs should have been automatically updated - output = self.widget.roiWidget.getRois() - selection = numpy.nonzero((-x >= output["negative"]["from"]) & \ - (-x <= output["negative"]["to"]))[0] - self.assertEqual(output["negative"]["rawcounts"], - y[selection].sum(), "Calculation failed on negative X coordinates") + self.assertEqual(roi_pos.computeRawAndNetCounts(posCurve), + (y[10:21].sum(), 0.0)) + self.assertEqual(roi_pos.computeRawAndNetCounts(negCurve), + (0.0, 0.0)) + self.assertEqual(roi_neg.computeRawAndNetCounts(posCurve), + ((0.0), 0.0)) + self.assertEqual(roi_neg.computeRawAndNetCounts(negCurve), + (y[10:21].sum(), 0.0)) def testDeferedInit(self): + """Test behavior of the deferedInit""" x = numpy.arange(100.) y = numpy.arange(100.) self.plot.addCurve(x=x, y=y, legend="name", replace="True") @@ -164,12 +206,123 @@ class TestCurvesROIWidget(TestCaseQt): ]) roiWidget = self.plot.getCurvesRoiDockWidget().roiWidget - self.assertFalse(roiWidget._isInit) self.plot.getCurvesRoiDockWidget().setRois(roisDefs) self.assertTrue(len(roiWidget.getRois()) is len(roisDefs)) self.plot.getCurvesRoiDockWidget().setVisible(True) self.assertTrue(len(roiWidget.getRois()) is len(roisDefs)) + def testDictCompatibility(self): + """Test that ROI api is valid with dict and not information is lost""" + roiDict = {'from': 20, 'to': 200, 'type': 'energy', 'comment': 'no', + 'name': 'myROI', 'calibration': [1, 2, 3]} + roi = CurvesROIWidget.ROI._fromDict(roiDict) + self.assertTrue(roi.toDict() == roiDict) + + def testShowAllROI(self): + """Test the show allROI action""" + x = numpy.arange(100.) + y = numpy.arange(100.) + self.plot.addCurve(x=x, y=y, legend="name", replace="True") + + roisDefsDict = { + "range1": {"from": 20, "to": 200,"type": "energy"}, + "range2": {"from": 300, "to": 500, "type": "energy"} + } + + roisDefsObj = ( + CurvesROIWidget.ROI(name='range3', fromdata=20, todata=200, + type_='energy'), + CurvesROIWidget.ROI(name='range4', fromdata=300, todata=500, + type_='energy') + ) + self.widget.roiWidget.showAllMarkers(True) + roiWidget = self.plot.getCurvesRoiDockWidget().roiWidget + roiWidget.setRois(roisDefsDict) + self.assertTrue(len(self.plot._getAllMarkers()) is 2*3) + + markersHandler = self.widget.roiWidget.roiTable._markersHandler + roiWidget.showAllMarkers(True) + ICRROI = markersHandler.getVisibleRois() + self.assertTrue(len(ICRROI) is 2) + + roiWidget.showAllMarkers(False) + ICRROI = markersHandler.getVisibleRois() + self.assertTrue(len(ICRROI) is 1) + + roiWidget.setRois(roisDefsObj) + self.qapp.processEvents() + self.assertTrue(len(self.plot._getAllMarkers()) is 2*3) + + markersHandler = self.widget.roiWidget.roiTable._markersHandler + roiWidget.showAllMarkers(True) + ICRROI = markersHandler.getVisibleRois() + self.assertTrue(len(ICRROI) is 2) + + roiWidget.showAllMarkers(False) + ICRROI = markersHandler.getVisibleRois() + self.assertTrue(len(ICRROI) is 1) + + def testRoiEdition(self): + """Make sure if the ROI object is edited the ROITable will be updated + """ + roi = CurvesROIWidget.ROI(name='linear', fromdata=0, todata=5) + self.widget.roiWidget.setRois((roi, )) + + x = (0, 1, 1, 2, 2, 3) + y = (1, 1, 2, 2, 1, 1) + self.plot.addCurve(x=x, y=y, legend='linearCurve') + self.plot.setActiveCurve(legend='linearCurve') + self.widget.calculateROIs() + + roiTable = self.widget.roiWidget.roiTable + indexesColumns = CurvesROIWidget.ROITable.COLUMNS_INDEX + itemRawCounts = roiTable.item(0, indexesColumns['Raw Counts']) + itemNetCounts = roiTable.item(0, indexesColumns['Net Counts']) + + self.assertTrue(itemRawCounts.text() == '8.0') + self.assertTrue(itemNetCounts.text() == '2.0') + + itemRawArea = roiTable.item(0, indexesColumns['Raw Area']) + itemNetArea = roiTable.item(0, indexesColumns['Net Area']) + + self.assertTrue(itemRawArea.text() == '4.0') + self.assertTrue(itemNetArea.text() == '1.0') + + roi.setTo(2) + itemRawArea = roiTable.item(0, indexesColumns['Raw Area']) + self.assertTrue(itemRawArea.text() == '3.0') + roi.setFrom(1) + itemRawArea = roiTable.item(0, indexesColumns['Raw Area']) + self.assertTrue(itemRawArea.text() == '2.0') + + def testRemoveActiveROI(self): + """Test widget behavior when removing the active ROI""" + roi = CurvesROIWidget.ROI(name='linear', fromdata=0, todata=5) + self.widget.roiWidget.setRois((roi,)) + + self.widget.roiWidget.roiTable.setActiveRoi(None) + self.assertTrue(len(self.widget.roiWidget.roiTable.selectedItems()) is 0) + self.widget.roiWidget.setRois((roi,)) + self.plot.setActiveCurve(legend='linearCurve') + self.widget.calculateROIs() + + def testEmitCurrentROI(self): + """Test behavior of the CurvesROIWidget.sigROISignal""" + roi = CurvesROIWidget.ROI(name='linear', fromdata=0, todata=5) + self.widget.roiWidget.setRois((roi,)) + signalListener = SignalListener() + self.widget.roiWidget.sigROISignal.connect(signalListener.partial()) + self.widget.show() + self.qapp.processEvents() + self.assertTrue(signalListener.callCount() is 0) + self.assertTrue(self.widget.roiWidget.roiTable.activeRoi is roi) + roi.setFrom(0.0) + self.qapp.processEvents() + self.assertTrue(signalListener.callCount() is 0) + roi.setFrom(0.3) + self.qapp.processEvents() + self.assertTrue(signalListener.callCount() is 1) + def suite(): test_suite = unittest.TestSuite() diff --git a/silx/gui/plot/test/testMaskToolsWidget.py b/silx/gui/plot/test/testMaskToolsWidget.py index 6912ea3..a05c1be 100644 --- a/silx/gui/plot/test/testMaskToolsWidget.py +++ b/silx/gui/plot/test/testMaskToolsWidget.py @@ -42,10 +42,7 @@ from silx.gui.utils.testutils import getQToolButtonFromAction from silx.gui.plot import PlotWindow, MaskToolsWidget from .utils import PlotWidgetTestCase -try: - import fabio -except ImportError: - fabio = None +import fabio _logger = logging.getLogger(__name__) @@ -254,8 +251,6 @@ class TestMaskToolsWidget(PlotWidgetTestCase, ParametricTestCase): self.__loadSave("npy") def testLoadSaveFit2D(self): - if fabio is None: - self.skipTest("Fabio is missing") self.__loadSave("msk") def testSigMaskChangedEmitted(self): diff --git a/silx/gui/plot/test/testPlotWidget.py b/silx/gui/plot/test/testPlotWidget.py index 857b9bc..9d7c093 100644 --- a/silx/gui/plot/test/testPlotWidget.py +++ b/silx/gui/plot/test/testPlotWidget.py @@ -1,7 +1,7 @@ # coding: utf-8 # /*########################################################################## # -# Copyright (c) 2016-2018 European Synchrotron Radiation Facility +# Copyright (c) 2016-2019 European Synchrotron Radiation Facility # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal @@ -26,7 +26,7 @@ __authors__ = ["T. Vincent"] __license__ = "MIT" -__date__ = "21/09/2018" +__date__ = "03/01/2019" import unittest @@ -36,8 +36,6 @@ import numpy from silx.utils.testutils import ParametricTestCase, parameterize from silx.gui.utils.testutils import SignalListener from silx.gui.utils.testutils import TestCaseQt -from silx.utils import testutils -from silx.utils import deprecation from silx.test.utils import test_options @@ -184,6 +182,39 @@ class TestPlotWidget(PlotWidgetTestCase, ParametricTestCase): self.assertTrue(numpy.all(numpy.equal(items[4].getPosition()[0], marker_x))) self.assertEqual(items[5].getType(), 'rectangle') + def testBackGroundColors(self): + self.plot.setVisible(True) + self.qWaitForWindowExposed(self.plot) + self.qapp.processEvents() + + # Custom the full background + color = self.plot.getBackgroundColor() + self.assertTrue(color.isValid()) + self.assertEqual(color, qt.QColor(255, 255, 255)) + self.plot.setBackgroundColor("red") + color = self.plot.getBackgroundColor() + self.assertTrue(color.isValid()) + self.qapp.processEvents() + + # Custom the data background + color = self.plot.getDataBackgroundColor() + self.assertFalse(color.isValid()) + self.plot.setDataBackgroundColor("red") + color = self.plot.getDataBackgroundColor() + self.assertTrue(color.isValid()) + self.qapp.processEvents() + + # Back to default + self.plot.setBackgroundColor('white') + self.plot.setDataBackgroundColor(None) + color = self.plot.getBackgroundColor() + self.assertTrue(color.isValid()) + self.assertEqual(color, qt.QColor(255, 255, 255)) + color = self.plot.getDataBackgroundColor() + self.assertFalse(color.isValid()) + self.qapp.processEvents() + + class TestPlotImage(PlotWidgetTestCase, ParametricTestCase): """Basic tests for addImage""" @@ -881,17 +912,12 @@ class TestPlotAxes(TestCaseQt, ParametricTestCase): if getter is not None: self.assertEqual(getter(), expected) - @testutils.test_logging(deprecation.depreclog.name) def testOldPlotAxis_Logarithmic(self): """Test silx API prior to silx 0.6""" x = self.plot.getXAxis() y = self.plot.getYAxis() yright = self.plot.getYAxis(axis="right") - listener = SignalListener() - self.plot.sigSetXAxisLogarithmic.connect(listener.partial("x")) - self.plot.sigSetYAxisLogarithmic.connect(listener.partial("y")) - self.assertEqual(x.getScale(), x.LINEAR) self.assertEqual(y.getScale(), x.LINEAR) self.assertEqual(yright.getScale(), x.LINEAR) @@ -902,7 +928,6 @@ class TestPlotAxes(TestCaseQt, ParametricTestCase): self.assertEqual(yright.getScale(), x.LINEAR) self.assertEqual(self.plot.isXAxisLogarithmic(), True) self.assertEqual(self.plot.isYAxisLogarithmic(), False) - self.assertEqual(listener.arguments(callIndex=-1), ("x", True)) self.plot.setYAxisLogarithmic(True) self.assertEqual(x.getScale(), x.LOGARITHMIC) @@ -910,7 +935,6 @@ class TestPlotAxes(TestCaseQt, ParametricTestCase): self.assertEqual(yright.getScale(), x.LOGARITHMIC) self.assertEqual(self.plot.isXAxisLogarithmic(), True) self.assertEqual(self.plot.isYAxisLogarithmic(), True) - self.assertEqual(listener.arguments(callIndex=-1), ("y", True)) yright.setScale(yright.LINEAR) self.assertEqual(x.getScale(), x.LOGARITHMIC) @@ -918,19 +942,13 @@ class TestPlotAxes(TestCaseQt, ParametricTestCase): self.assertEqual(yright.getScale(), x.LINEAR) self.assertEqual(self.plot.isXAxisLogarithmic(), True) self.assertEqual(self.plot.isYAxisLogarithmic(), False) - self.assertEqual(listener.arguments(callIndex=-1), ("y", False)) - @testutils.test_logging(deprecation.depreclog.name) def testOldPlotAxis_AutoScale(self): """Test silx API prior to silx 0.6""" x = self.plot.getXAxis() y = self.plot.getYAxis() yright = self.plot.getYAxis(axis="right") - listener = SignalListener() - self.plot.sigSetXAxisAutoScale.connect(listener.partial("x")) - self.plot.sigSetYAxisAutoScale.connect(listener.partial("y")) - self.assertEqual(x.isAutoScale(), True) self.assertEqual(y.isAutoScale(), True) self.assertEqual(yright.isAutoScale(), True) @@ -941,7 +959,6 @@ class TestPlotAxes(TestCaseQt, ParametricTestCase): self.assertEqual(yright.isAutoScale(), True) self.assertEqual(self.plot.isXAxisAutoScale(), False) self.assertEqual(self.plot.isYAxisAutoScale(), True) - self.assertEqual(listener.arguments(callIndex=-1), ("x", False)) self.plot.setYAxisAutoScale(False) self.assertEqual(x.isAutoScale(), False) @@ -949,7 +966,6 @@ class TestPlotAxes(TestCaseQt, ParametricTestCase): self.assertEqual(yright.isAutoScale(), False) self.assertEqual(self.plot.isXAxisAutoScale(), False) self.assertEqual(self.plot.isYAxisAutoScale(), False) - self.assertEqual(listener.arguments(callIndex=-1), ("y", False)) yright.setAutoScale(True) self.assertEqual(x.isAutoScale(), False) @@ -957,18 +973,13 @@ class TestPlotAxes(TestCaseQt, ParametricTestCase): self.assertEqual(yright.isAutoScale(), True) self.assertEqual(self.plot.isXAxisAutoScale(), False) self.assertEqual(self.plot.isYAxisAutoScale(), True) - self.assertEqual(listener.arguments(callIndex=-1), ("y", True)) - @testutils.test_logging(deprecation.depreclog.name) def testOldPlotAxis_Inverted(self): """Test silx API prior to silx 0.6""" x = self.plot.getXAxis() y = self.plot.getYAxis() yright = self.plot.getYAxis(axis="right") - listener = SignalListener() - self.plot.sigSetYAxisInverted.connect(listener.partial("y")) - self.assertEqual(x.isInverted(), False) self.assertEqual(y.isInverted(), False) self.assertEqual(yright.isInverted(), False) @@ -978,14 +989,12 @@ class TestPlotAxes(TestCaseQt, ParametricTestCase): self.assertEqual(y.isInverted(), True) self.assertEqual(yright.isInverted(), True) self.assertEqual(self.plot.isYAxisInverted(), True) - self.assertEqual(listener.arguments(callIndex=-1), ("y", True)) yright.setInverted(False) self.assertEqual(x.isInverted(), False) self.assertEqual(y.isInverted(), False) self.assertEqual(yright.isInverted(), False) self.assertEqual(self.plot.isYAxisInverted(), False) - self.assertEqual(listener.arguments(callIndex=-1), ("y", False)) def testLogXWithData(self): self.plot.setGraphTitle('Curve X: Log Y: Linear') diff --git a/silx/gui/plot/test/testSaveAction.py b/silx/gui/plot/test/testSaveAction.py index 85669bf..0eb129d 100644 --- a/silx/gui/plot/test/testSaveAction.py +++ b/silx/gui/plot/test/testSaveAction.py @@ -1,7 +1,7 @@ # coding: utf-8 # /*########################################################################## # -# Copyright (c) 2017-2018 European Synchrotron Radiation Facility +# Copyright (c) 2017-2019 European Synchrotron Radiation Facility # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal @@ -106,12 +106,30 @@ class TestSaveActionExtension(PlotWidgetTestCase): self.assertEqual(saveAction.getFileFilters('all')[nameFilter], self._dummySaveFunction) + # Add a new file filter at a particular position + nameFilter = 'Dummy file2 (*.dummy)' + saveAction.setFileFilter('all', nameFilter, + self._dummySaveFunction, index=3) + self.assertTrue(nameFilter in saveAction.getFileFilters('all')) + filters = saveAction.getFileFilters('all') + self.assertEqual(filters[nameFilter], self._dummySaveFunction) + self.assertEqual(list(filters.keys()).index(nameFilter),3) + # Update an existing file filter nameFilter = SaveAction.IMAGE_FILTER_EDF saveAction.setFileFilter('image', nameFilter, self._dummySaveFunction) self.assertEqual(saveAction.getFileFilters('image')[nameFilter], self._dummySaveFunction) + # Change the position of an existing file filter + nameFilter = 'Dummy file2 (*.dummy)' + oldIndex = list(saveAction.getFileFilters('all')).index(nameFilter) + newIndex = oldIndex - 1 + saveAction.setFileFilter('all', nameFilter, + self._dummySaveFunction, index=newIndex) + filters = saveAction.getFileFilters('all') + self.assertEqual(filters[nameFilter], self._dummySaveFunction) + self.assertEqual(list(filters.keys()).index(nameFilter), newIndex) def suite(): test_suite = unittest.TestSuite() diff --git a/silx/gui/plot/test/testScatterMaskToolsWidget.py b/silx/gui/plot/test/testScatterMaskToolsWidget.py index a446911..171ec42 100644 --- a/silx/gui/plot/test/testScatterMaskToolsWidget.py +++ b/silx/gui/plot/test/testScatterMaskToolsWidget.py @@ -42,10 +42,7 @@ from silx.gui.utils.testutils import getQToolButtonFromAction from silx.gui.plot import PlotWindow, ScatterMaskToolsWidget from .utils import PlotWidgetTestCase -try: - import fabio -except ImportError: - fabio = None +import fabio _logger = logging.getLogger(__name__) diff --git a/silx/gui/plot/test/testStats.py b/silx/gui/plot/test/testStats.py index faedcff..7fbc247 100644 --- a/silx/gui/plot/test/testStats.py +++ b/silx/gui/plot/test/testStats.py @@ -1,7 +1,7 @@ # coding: utf-8 # /*########################################################################## # -# Copyright (c) 2016-2018 European Synchrotron Radiation Facility +# Copyright (c) 2016-2019 European Synchrotron Radiation Facility # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal @@ -112,34 +112,34 @@ class TestStats(TestCaseQt): """Test result for simple stats on a curve""" _stats = self.getBasicStats() xData = yData = numpy.array(range(20)) - self.assertTrue(_stats['min'].calculate(self.curveContext) == 0) - self.assertTrue(_stats['max'].calculate(self.curveContext) == 19) - self.assertTrue(_stats['minCoords'].calculate(self.curveContext) == [0]) - self.assertTrue(_stats['maxCoords'].calculate(self.curveContext) == [19]) - self.assertTrue(_stats['std'].calculate(self.curveContext) == numpy.std(yData)) - self.assertTrue(_stats['mean'].calculate(self.curveContext) == numpy.mean(yData)) + self.assertEqual(_stats['min'].calculate(self.curveContext), 0) + self.assertEqual(_stats['max'].calculate(self.curveContext), 19) + self.assertEqual(_stats['minCoords'].calculate(self.curveContext), (0,)) + self.assertEqual(_stats['maxCoords'].calculate(self.curveContext), (19,)) + self.assertEqual(_stats['std'].calculate(self.curveContext), numpy.std(yData)) + self.assertEqual(_stats['mean'].calculate(self.curveContext), numpy.mean(yData)) com = numpy.sum(xData * yData) / numpy.sum(yData) - self.assertTrue(_stats['com'].calculate(self.curveContext) == com) + self.assertEqual(_stats['com'].calculate(self.curveContext), com) def testBasicStatsImage(self): """Test result for simple stats on an image""" _stats = self.getBasicStats() - self.assertTrue(_stats['min'].calculate(self.imageContext) == 0) - self.assertTrue(_stats['max'].calculate(self.imageContext) == 128 * 32 - 1) - self.assertTrue(_stats['minCoords'].calculate(self.imageContext) == (0, 0)) - self.assertTrue(_stats['maxCoords'].calculate(self.imageContext) == (127, 31)) - self.assertTrue(_stats['std'].calculate(self.imageContext) == numpy.std(self.imageData)) - self.assertTrue(_stats['mean'].calculate(self.imageContext) == numpy.mean(self.imageData)) - - yData = numpy.sum(self.imageData, axis=1) - xData = numpy.sum(self.imageData, axis=0) + self.assertEqual(_stats['min'].calculate(self.imageContext), 0) + self.assertEqual(_stats['max'].calculate(self.imageContext), 128 * 32 - 1) + self.assertEqual(_stats['minCoords'].calculate(self.imageContext), (0, 0)) + self.assertEqual(_stats['maxCoords'].calculate(self.imageContext), (127, 31)) + self.assertEqual(_stats['std'].calculate(self.imageContext), numpy.std(self.imageData)) + self.assertEqual(_stats['mean'].calculate(self.imageContext), numpy.mean(self.imageData)) + + yData = numpy.sum(self.imageData.astype(numpy.float64), axis=1) + xData = numpy.sum(self.imageData.astype(numpy.float64), axis=0) dataXRange = range(self.imageData.shape[1]) dataYRange = range(self.imageData.shape[0]) ycom = numpy.sum(yData*dataYRange) / numpy.sum(yData) xcom = numpy.sum(xData*dataXRange) / numpy.sum(xData) - self.assertTrue(_stats['com'].calculate(self.imageContext) == (xcom, ycom)) + self.assertEqual(_stats['com'].calculate(self.imageContext), (xcom, ycom)) def testStatsImageAdv(self): """Test that scale and origin are taking into account for images""" @@ -153,52 +153,46 @@ class TestStats(TestCaseQt): onlimits=False ) _stats = self.getBasicStats() - self.assertTrue(_stats['min'].calculate(image2Context) == 0) - self.assertTrue( - _stats['max'].calculate(image2Context) == 128 * 32 - 1) - self.assertTrue( - _stats['minCoords'].calculate(image2Context) == (100, 10)) - self.assertTrue( - _stats['maxCoords'].calculate(image2Context) == (127*2. + 100, - 31 * 0.5 + 10) - ) - self.assertTrue( - _stats['std'].calculate(image2Context) == numpy.std( - self.imageData)) - self.assertTrue( - _stats['mean'].calculate(image2Context) == numpy.mean( - self.imageData)) + self.assertEqual(_stats['min'].calculate(image2Context), 0) + self.assertEqual( + _stats['max'].calculate(image2Context), 128 * 32 - 1) + self.assertEqual( + _stats['minCoords'].calculate(image2Context), (100, 10)) + self.assertEqual( + _stats['maxCoords'].calculate(image2Context), (127*2. + 100, + 31 * 0.5 + 10)) + self.assertEqual(_stats['std'].calculate(image2Context), + numpy.std(self.imageData)) + self.assertEqual(_stats['mean'].calculate(image2Context), + numpy.mean(self.imageData)) yData = numpy.sum(self.imageData, axis=1) xData = numpy.sum(self.imageData, axis=0) - dataXRange = range(self.imageData.shape[1]) - dataYRange = range(self.imageData.shape[0]) + dataXRange = numpy.arange(self.imageData.shape[1], dtype=numpy.float64) + dataYRange = numpy.arange(self.imageData.shape[0], dtype=numpy.float64) ycom = numpy.sum(yData * dataYRange) / numpy.sum(yData) ycom = (ycom * 0.5) + 10 xcom = numpy.sum(xData * dataXRange) / numpy.sum(xData) xcom = (xcom * 2.) + 100 - self.assertTrue( - _stats['com'].calculate(image2Context) == (xcom, ycom)) + self.assertTrue(numpy.allclose( + _stats['com'].calculate(image2Context), (xcom, ycom))) def testBasicStatsScatter(self): """Test result for simple stats on a scatter""" _stats = self.getBasicStats() - self.assertTrue(_stats['min'].calculate(self.scatterContext) == 5) - self.assertTrue(_stats['max'].calculate(self.scatterContext) == 90) - self.assertTrue(_stats['minCoords'].calculate(self.scatterContext) == (0, 2)) - self.assertTrue(_stats['maxCoords'].calculate(self.scatterContext) == (50, 69)) - self.assertTrue(_stats['std'].calculate(self.scatterContext) == numpy.std(self.valuesScatterData)) - self.assertTrue(_stats['mean'].calculate(self.scatterContext) == numpy.mean(self.valuesScatterData)) - - comx = numpy.sum(self.xScatterData * self.valuesScatterData).astype(numpy.float32) / numpy.sum( - self.valuesScatterData).astype(numpy.float32) - comy = numpy.sum(self.yScatterData * self.valuesScatterData).astype(numpy.float32) / numpy.sum( - self.valuesScatterData).astype(numpy.float32) - self.assertTrue(numpy.all( - numpy.equal(_stats['com'].calculate(self.scatterContext), - (comx, comy))) - ) + self.assertEqual(_stats['min'].calculate(self.scatterContext), 5) + self.assertEqual(_stats['max'].calculate(self.scatterContext), 90) + self.assertEqual(_stats['minCoords'].calculate(self.scatterContext), (0, 2)) + self.assertEqual(_stats['maxCoords'].calculate(self.scatterContext), (50, 69)) + self.assertEqual(_stats['std'].calculate(self.scatterContext), numpy.std(self.valuesScatterData)) + self.assertEqual(_stats['mean'].calculate(self.scatterContext), numpy.mean(self.valuesScatterData)) + + data = self.valuesScatterData.astype(numpy.float64) + comx = numpy.sum(self.xScatterData * data) / numpy.sum(data) + comy = numpy.sum(self.yScatterData * data) / numpy.sum(data) + self.assertEqual(_stats['com'].calculate(self.scatterContext), + (comx, comy)) def testKindNotManagedByStat(self): """Make sure an exception is raised if we try to execute calculate @@ -227,21 +221,21 @@ class TestStats(TestCaseQt): item=self.plot1d.getCurve('curve0'), plot=self.plot1d, onlimits=True) - self.assertTrue(stat.calculate(curveContextOnLimits) == 2) + self.assertEqual(stat.calculate(curveContextOnLimits), 2) self.plot2d.getXAxis().setLimitsConstraints(minPos=32) imageContextOnLimits = stats._ImageContext( item=self.plot2d.getImage('test image'), plot=self.plot2d, onlimits=True) - self.assertTrue(stat.calculate(imageContextOnLimits) == 32) + self.assertEqual(stat.calculate(imageContextOnLimits), 32) self.scatterPlot.getXAxis().setLimitsConstraints(minPos=40) scatterContextOnLimits = stats._ScatterContext( item=self.scatterPlot.getScatter('scatter plot'), plot=self.scatterPlot, onlimits=True) - self.assertTrue(stat.calculate(scatterContextOnLimits) == 20) + self.assertEqual(stat.calculate(scatterContextOnLimits), 20) class TestStatsFormatter(TestCaseQt): @@ -267,15 +261,15 @@ class TestStatsFormatter(TestCaseQt): """Make sure a formatter with no formatter definition will return a simple cast to str""" emptyFormatter = statshandler.StatFormatter() - self.assertTrue( - emptyFormatter.format(self.stat.calculate(self.curveContext)) == '0.000') + self.assertEqual( + emptyFormatter.format(self.stat.calculate(self.curveContext)), '0.000') def testSettedFormatter(self): """Make sure a formatter with no formatter definition will return a simple cast to str""" formatter= statshandler.StatFormatter(formatter='{0:.3f}') - self.assertTrue( - formatter.format(self.stat.calculate(self.curveContext)) == '0.000') + self.assertEqual( + formatter.format(self.stat.calculate(self.curveContext)), '0.000') class TestStatsHandler(unittest.TestCase): @@ -309,9 +303,9 @@ class TestStatsHandler(unittest.TestCase): res = handler0.calculate(item=self.curveItem, plot=self.plot1d, onlimits=False) self.assertTrue('min' in res) - self.assertTrue(res['min'] == '0') + self.assertEqual(res['min'], '0') self.assertTrue('max' in res) - self.assertTrue(res['max'] == '19') + self.assertEqual(res['max'], '19') handler1 = statshandler.StatsHandler( ( @@ -323,9 +317,9 @@ class TestStatsHandler(unittest.TestCase): res = handler1.calculate(item=self.curveItem, plot=self.plot1d, onlimits=False) self.assertTrue('min' in res) - self.assertTrue(res['min'] == '0') + self.assertEqual(res['min'], '0') self.assertTrue('max' in res) - self.assertTrue(res['max'] == '19.000') + self.assertEqual(res['max'], '19.000') handler2 = statshandler.StatsHandler( ( @@ -336,9 +330,9 @@ class TestStatsHandler(unittest.TestCase): res = handler2.calculate(item=self.curveItem, plot=self.plot1d, onlimits=False) self.assertTrue('min' in res) - self.assertTrue(res['min'] == '0') + self.assertEqual(res['min'], '0') self.assertTrue('max' in res) - self.assertTrue(res['max'] == '19.000') + self.assertEqual(res['max'], '19.000') handler3 = statshandler.StatsHandler(( (('amin', numpy.argmin), statshandler.StatFormatter()), @@ -348,9 +342,9 @@ class TestStatsHandler(unittest.TestCase): res = handler3.calculate(item=self.curveItem, plot=self.plot1d, onlimits=False) self.assertTrue('amin' in res) - self.assertTrue(res['amin'] == '0.000') + self.assertEqual(res['amin'], '0.000') self.assertTrue('amax' in res) - self.assertTrue(res['amax'] == '19') + self.assertEqual(res['amax'], '19') with self.assertRaises(ValueError): statshandler.StatsHandler(('name')) @@ -395,47 +389,49 @@ class TestStatsWidgetWithCurves(TestCaseQt): def testInit(self): """Make sure all the curves are registred on initialization""" - self.assertTrue(self.widget.rowCount() is 3) + self.assertEqual(self.widget.rowCount(), 3) def testRemoveCurve(self): """Make sure the Curves stats take into account the curve removal from plot""" self.plot.removeCurve('curve2') - self.assertTrue(self.widget.rowCount() is 2) + self.assertEqual(self.widget.rowCount(), 2) for iRow in range(2): self.assertTrue(self.widget.item(iRow, 0).text() in ('curve0', 'curve1')) self.plot.removeCurve('curve0') - self.assertTrue(self.widget.rowCount() is 1) + self.assertEqual(self.widget.rowCount(), 1) self.plot.removeCurve('curve1') - self.assertTrue(self.widget.rowCount() is 0) + self.assertEqual(self.widget.rowCount(), 0) def testAddCurve(self): """Make sure the Curves stats take into account the add curve action""" self.plot.addCurve(legend='curve3', x=range(10), y=range(10)) - self.assertTrue(self.widget.rowCount() is 4) + self.assertEqual(self.widget.rowCount(), 4) - def testUpdateCurveFrmAddCurve(self): + def testUpdateCurveFromAddCurve(self): """Make sure the stats of the cuve will be removed after updating a curve""" self.plot.addCurve(legend='curve0', x=range(10), y=range(10)) - self.assertTrue(self.widget.rowCount() is 3) - itemMax = self.widget._getItem(name='max', legend='curve0', - kind='curve', indexTable=None) - self.assertTrue(itemMax.text() == '9') + self.qapp.processEvents() + self.assertEqual(self.widget.rowCount(), 3) + curve = self.plot._getItem(kind='curve', legend='curve0') + tableItems = self.widget._itemToTableItems(curve) + self.assertEqual(tableItems['max'].text(), '9') - def testUpdateCurveFrmCurveObj(self): + def testUpdateCurveFromCurveObj(self): self.plot.getCurve('curve0').setData(x=range(4), y=range(4)) - self.assertTrue(self.widget.rowCount() is 3) - itemMax = self.widget._getItem(name='max', legend='curve0', - kind='curve', indexTable=None) - self.assertTrue(itemMax.text() == '3') + self.qapp.processEvents() + self.assertEqual(self.widget.rowCount(), 3) + curve = self.plot._getItem(kind='curve', legend='curve0') + tableItems = self.widget._itemToTableItems(curve) + self.assertEqual(tableItems['max'].text(), '3') def testSetAnotherPlot(self): plot2 = Plot1D() plot2.addCurve(x=range(26), y=range(26), legend='new curve') self.widget.setPlot(plot2) - self.assertTrue(self.widget.rowCount() is 1) + self.assertEqual(self.widget.rowCount(), 1) self.qapp.processEvents() plot2.setAttribute(qt.Qt.WA_DeleteOnClose) plot2.close() @@ -444,12 +440,15 @@ class TestStatsWidgetWithCurves(TestCaseQt): class TestStatsWidgetWithImages(TestCaseQt): """Basic test for StatsWidget with images""" + + IMAGE_LEGEND = 'test image' + def setUp(self): TestCaseQt.setUp(self) self.plot = Plot2D() self.plot.addImage(data=numpy.arange(128*128).reshape(128, 128), - legend='test image', replace=False) + legend=self.IMAGE_LEGEND, replace=False) self.widget = StatsWidget.StatsTable(plot=self.plot) @@ -476,31 +475,30 @@ class TestStatsWidgetWithImages(TestCaseQt): TestCaseQt.tearDown(self) def test(self): - columnsIndex = self.widget._columns_index - itemLegend = self.widget._lgdAndKindToItems[('test image', 'image')]['legend'] - itemMin = self.widget.item(itemLegend.row(), columnsIndex['min']) - itemMax = self.widget.item(itemLegend.row(), columnsIndex['max']) - itemDelta = self.widget.item(itemLegend.row(), columnsIndex['delta']) - itemCoordsMin = self.widget.item(itemLegend.row(), - columnsIndex['coords min']) - itemCoordsMax = self.widget.item(itemLegend.row(), - columnsIndex['coords max']) - max = (128 * 128) - 1 - self.assertTrue(itemMin.text() == '0.000') - self.assertTrue(itemMax.text() == '{0:.3f}'.format(max)) - self.assertTrue(itemDelta.text() == '{0:.3f}'.format(max)) - self.assertTrue(itemCoordsMin.text() == '0.0, 0.0') - self.assertTrue(itemCoordsMax.text() == '127.0, 127.0') + image = self.plot._getItem( + kind='image', legend=self.IMAGE_LEGEND) + tableItems = self.widget._itemToTableItems(image) + + maxText = '{0:.3f}'.format((128 * 128) - 1) + self.assertEqual(tableItems['legend'].text(), self.IMAGE_LEGEND) + self.assertEqual(tableItems['min'].text(), '0.000') + self.assertEqual(tableItems['max'].text(), maxText) + self.assertEqual(tableItems['delta'].text(), maxText) + self.assertEqual(tableItems['coords min'].text(), '0.0, 0.0') + self.assertEqual(tableItems['coords max'].text(), '127.0, 127.0') class TestStatsWidgetWithScatters(TestCaseQt): + + SCATTER_LEGEND = 'scatter plot' + def setUp(self): TestCaseQt.setUp(self) self.scatterPlot = Plot2D() self.scatterPlot.addScatter([0, 1, 2, 20, 50, 60], [2, 3, 4, 26, 69, 6], [5, 6, 7, 10, 90, 20], - legend='scatter plot') + legend=self.SCATTER_LEGEND) self.widget = StatsWidget.StatsTable(plot=self.scatterPlot) mystats = statshandler.StatsHandler(( @@ -526,33 +524,89 @@ class TestStatsWidgetWithScatters(TestCaseQt): TestCaseQt.tearDown(self) def testStats(self): - columnsIndex = self.widget._columns_index - itemLegend = self.widget._lgdAndKindToItems[('scatter plot', 'scatter')]['legend'] - itemMin = self.widget.item(itemLegend.row(), columnsIndex['min']) - itemMax = self.widget.item(itemLegend.row(), columnsIndex['max']) - itemDelta = self.widget.item(itemLegend.row(), columnsIndex['delta']) - itemCoordsMin = self.widget.item(itemLegend.row(), - columnsIndex['coords min']) - itemCoordsMax = self.widget.item(itemLegend.row(), - columnsIndex['coords max']) - self.assertTrue(itemMin.text() == '5') - self.assertTrue(itemMax.text() == '90') - self.assertTrue(itemDelta.text() == '85') - self.assertTrue(itemCoordsMin.text() == '0, 2') - self.assertTrue(itemCoordsMax.text() == '50, 69') + scatter = self.scatterPlot._getItem( + kind='scatter', legend=self.SCATTER_LEGEND) + tableItems = self.widget._itemToTableItems(scatter) + self.assertEqual(tableItems['legend'].text(), self.SCATTER_LEGEND) + self.assertEqual(tableItems['min'].text(), '5') + self.assertEqual(tableItems['coords min'].text(), '0, 2') + self.assertEqual(tableItems['max'].text(), '90') + self.assertEqual(tableItems['coords max'].text(), '50, 69') + self.assertEqual(tableItems['delta'].text(), '85') class TestEmptyStatsWidget(TestCaseQt): def test(self): widget = StatsWidget.StatsWidget() widget.show() + self.qWaitForWindowExposed(widget) + + +# skip unit test for pyqt4 because there is some unrealised widget without +# apparent reason +@unittest.skipIf(qt.qVersion().split('.')[0] == '4', reason='PyQt4 not tested') +class TestLineWidget(TestCaseQt): + """Some test for the StatsLineWidget.""" + def setUp(self): + TestCaseQt.setUp(self) + + mystats = statshandler.StatsHandler(( + (stats.StatMin(), statshandler.StatFormatter()), + )) + + self.plot = Plot1D() + self.plot.show() + x = range(20) + y = range(20) + self.plot.addCurve(x, y, legend='curve0') + y = range(12, 32) + self.plot.addCurve(x, y, legend='curve1') + y = range(-2, 18) + self.plot.addCurve(x, y, legend='curve2') + self.widget = StatsWidget.BasicGridStatsWidget(plot=self.plot, + kind='curve', + stats=mystats) + + def tearDown(self): + self.qapp.processEvents() + self.plot.setAttribute(qt.Qt.WA_DeleteOnClose) + self.plot.close() + self.widget.setPlot(None) + self.widget._statQlineEdit.clear() + self.widget.setAttribute(qt.Qt.WA_DeleteOnClose) + self.widget.close() + self.widget = None + self.plot = None + TestCaseQt.tearDown(self) + + def test(self): + self.widget.setStatsOnVisibleData(False) + self.qapp.processEvents() + self.plot.setActiveCurve(legend='curve0') + self.assertTrue(self.widget._statQlineEdit['min'].text() == '0.000') + self.plot.setActiveCurve(legend='curve1') + self.assertTrue(self.widget._statQlineEdit['min'].text() == '12.000') + self.plot.getXAxis().setLimitsConstraints(minPos=2, maxPos=5) + self.widget.setStatsOnVisibleData(True) + self.qapp.processEvents() + self.assertTrue(self.widget._statQlineEdit['min'].text() == '14.000') + self.plot.setActiveCurve(None) + self.assertTrue(self.plot.getActiveCurve() is None) + self.widget.setStatsOnVisibleData(False) + self.qapp.processEvents() + self.assertFalse(self.widget._statQlineEdit['min'].text() == '14.000') + self.widget.setKind('image') + self.plot.addImage(numpy.arange(100*100).reshape(100, 100) + 0.312) + self.qapp.processEvents() + self.assertTrue(self.widget._statQlineEdit['min'].text() == '0.312') def suite(): test_suite = unittest.TestSuite() for TestClass in (TestStats, TestStatsHandler, TestStatsWidgetWithScatters, TestStatsWidgetWithImages, TestStatsWidgetWithCurves, - TestStatsFormatter, TestEmptyStatsWidget): + TestStatsFormatter, TestEmptyStatsWidget, + TestLineWidget): test_suite.addTest( unittest.defaultTestLoader.loadTestsFromTestCase(TestClass)) return test_suite diff --git a/silx/gui/plot/test/testUtilsAxis.py b/silx/gui/plot/test/testUtilsAxis.py index 016fafe..64373b8 100644 --- a/silx/gui/plot/test/testUtilsAxis.py +++ b/silx/gui/plot/test/testUtilsAxis.py @@ -26,7 +26,7 @@ __authors__ = ["V. Valls"] __license__ = "MIT" -__date__ = "14/02/2018" +__date__ = "20/11/2018" import unittest @@ -155,6 +155,53 @@ class TestAxisSync(TestCaseQt): self.assertEqual(self.plot2.getYAxis().isInverted(), True) self.assertEqual(self.plot3.getYAxis().isInverted(), True) + def testSyncCenter(self): + """Test direction change""" + # Not the same scale + self.plot1.getXAxis().setLimits(0, 200) + self.plot2.getXAxis().setLimits(0, 20) + self.plot3.getXAxis().setLimits(0, 2) + _sync = SyncAxes([self.plot1.getXAxis(), self.plot2.getXAxis(), self.plot3.getXAxis()], + syncLimits=False, syncCenter=True) + + self.assertEqual(self.plot1.getXAxis().getLimits(), (0, 200)) + self.assertEqual(self.plot2.getXAxis().getLimits(), (100 - 10, 100 + 10)) + self.assertEqual(self.plot3.getXAxis().getLimits(), (100 - 1, 100 + 1)) + + def testSyncCenterAndZoom(self): + """Test direction change""" + # Not the same scale + self.plot1.getXAxis().setLimits(0, 200) + self.plot2.getXAxis().setLimits(0, 20) + self.plot3.getXAxis().setLimits(0, 2) + _sync = SyncAxes([self.plot1.getXAxis(), self.plot2.getXAxis(), self.plot3.getXAxis()], + syncLimits=False, syncCenter=True, syncZoom=True) + + # Supposing all the plots use the same size + self.assertEqual(self.plot1.getXAxis().getLimits(), (0, 200)) + self.assertEqual(self.plot2.getXAxis().getLimits(), (0, 200)) + self.assertEqual(self.plot3.getXAxis().getLimits(), (0, 200)) + + def testAddAxis(self): + """Test synchronization after construction""" + sync = SyncAxes([self.plot1.getXAxis(), self.plot2.getXAxis()]) + sync.addAxis(self.plot3.getXAxis()) + + self.plot1.getXAxis().setLimits(10, 500) + self.assertEqual(self.plot1.getXAxis().getLimits(), (10, 500)) + self.assertEqual(self.plot2.getXAxis().getLimits(), (10, 500)) + self.assertEqual(self.plot3.getXAxis().getLimits(), (10, 500)) + + def testRemoveAxis(self): + """Test synchronization after construction""" + sync = SyncAxes([self.plot1.getXAxis(), self.plot2.getXAxis(), self.plot3.getXAxis()]) + sync.removeAxis(self.plot3.getXAxis()) + + self.plot1.getXAxis().setLimits(10, 500) + self.assertEqual(self.plot1.getXAxis().getLimits(), (10, 500)) + self.assertEqual(self.plot2.getXAxis().getLimits(), (10, 500)) + self.assertNotEqual(self.plot3.getXAxis().getLimits(), (10, 500)) + def suite(): test_suite = unittest.TestSuite() |