summaryrefslogtreecommitdiff
path: root/src/silx/gui/plot/test/testUtilsAxis.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/silx/gui/plot/test/testUtilsAxis.py')
-rw-r--r--src/silx/gui/plot/test/testUtilsAxis.py77
1 files changed, 57 insertions, 20 deletions
diff --git a/src/silx/gui/plot/test/testUtilsAxis.py b/src/silx/gui/plot/test/testUtilsAxis.py
index 879ec73..d749845 100644
--- a/src/silx/gui/plot/test/testUtilsAxis.py
+++ b/src/silx/gui/plot/test/testUtilsAxis.py
@@ -28,7 +28,6 @@ __license__ = "MIT"
__date__ = "20/11/2018"
-import unittest
from silx.gui.plot import PlotWidget
from silx.gui.utils.testutils import TestCaseQt
from silx.gui.plot.utils.axis import SyncAxes
@@ -51,7 +50,9 @@ class TestAxisSync(TestCaseQt):
def testMoveFirstAxis(self):
"""Test synchronization after construction"""
- _sync = SyncAxes([self.plot1.getXAxis(), self.plot2.getXAxis(), self.plot3.getXAxis()])
+ _sync = SyncAxes(
+ [self.plot1.getXAxis(), self.plot2.getXAxis(), self.plot3.getXAxis()]
+ )
self.plot1.getXAxis().setLimits(10, 500)
self.assertEqual(self.plot1.getXAxis().getLimits(), (10, 500))
@@ -60,7 +61,9 @@ class TestAxisSync(TestCaseQt):
def testMoveSecondAxis(self):
"""Test synchronization after construction"""
- _sync = SyncAxes([self.plot1.getXAxis(), self.plot2.getXAxis(), self.plot3.getXAxis()])
+ _sync = SyncAxes(
+ [self.plot1.getXAxis(), self.plot2.getXAxis(), self.plot3.getXAxis()]
+ )
self.plot2.getXAxis().setLimits(10, 500)
self.assertEqual(self.plot1.getXAxis().getLimits(), (10, 500))
@@ -69,7 +72,9 @@ class TestAxisSync(TestCaseQt):
def testMoveTwoAxes(self):
"""Test synchronization after construction"""
- _sync = SyncAxes([self.plot1.getXAxis(), self.plot2.getXAxis(), self.plot3.getXAxis()])
+ _sync = SyncAxes(
+ [self.plot1.getXAxis(), self.plot2.getXAxis(), self.plot3.getXAxis()]
+ )
self.plot1.getXAxis().setLimits(1, 50)
self.plot2.getXAxis().setLimits(10, 500)
@@ -79,7 +84,9 @@ class TestAxisSync(TestCaseQt):
def testDestruction(self):
"""Test synchronization when sync object is destroyed"""
- sync = SyncAxes([self.plot1.getXAxis(), self.plot2.getXAxis(), self.plot3.getXAxis()])
+ sync = SyncAxes(
+ [self.plot1.getXAxis(), self.plot2.getXAxis(), self.plot3.getXAxis()]
+ )
del sync
self.plot1.getXAxis().setLimits(10, 500)
@@ -89,10 +96,13 @@ class TestAxisSync(TestCaseQt):
def testAxisDestruction(self):
"""Test synchronization when an axis disappear"""
- _sync = SyncAxes([self.plot1.getXAxis(), self.plot2.getXAxis(), self.plot3.getXAxis()])
+ _sync = SyncAxes(
+ [self.plot1.getXAxis(), self.plot2.getXAxis(), self.plot3.getXAxis()]
+ )
# Destroy the plot is possible
import weakref
+
plot = weakref.ref(self.plot2)
self.plot2 = None
result = self.qWaitForDestroy(plot)
@@ -105,7 +115,9 @@ class TestAxisSync(TestCaseQt):
def testStop(self):
"""Test synchronization after calling stop"""
- sync = SyncAxes([self.plot1.getXAxis(), self.plot2.getXAxis(), self.plot3.getXAxis()])
+ sync = SyncAxes(
+ [self.plot1.getXAxis(), self.plot2.getXAxis(), self.plot3.getXAxis()]
+ )
sync.stop()
self.plot1.getXAxis().setLimits(10, 500)
@@ -115,7 +127,9 @@ class TestAxisSync(TestCaseQt):
def testStopMovingStart(self):
"""Test synchronization after calling stop, moving an axis, then start again"""
- sync = SyncAxes([self.plot1.getXAxis(), self.plot2.getXAxis(), self.plot3.getXAxis()])
+ sync = SyncAxes(
+ [self.plot1.getXAxis(), self.plot2.getXAxis(), self.plot3.getXAxis()]
+ )
sync.stop()
self.plot1.getXAxis().setLimits(10, 500)
self.plot2.getXAxis().setLimits(1, 50)
@@ -129,26 +143,40 @@ class TestAxisSync(TestCaseQt):
def testDoubleStop(self):
"""Test double stop"""
- sync = SyncAxes([self.plot1.getXAxis(), self.plot2.getXAxis(), self.plot3.getXAxis()])
+ sync = SyncAxes(
+ [self.plot1.getXAxis(), self.plot2.getXAxis(), self.plot3.getXAxis()]
+ )
sync.stop()
self.assertRaises(RuntimeError, sync.stop)
def testDoubleStart(self):
"""Test double stop"""
- sync = SyncAxes([self.plot1.getXAxis(), self.plot2.getXAxis(), self.plot3.getXAxis()])
+ sync = SyncAxes(
+ [self.plot1.getXAxis(), self.plot2.getXAxis(), self.plot3.getXAxis()]
+ )
self.assertRaises(RuntimeError, sync.start)
def testScale(self):
"""Test scale change"""
- _sync = SyncAxes([self.plot1.getXAxis(), self.plot2.getXAxis(), self.plot3.getXAxis()])
+ _sync = SyncAxes(
+ [self.plot1.getXAxis(), self.plot2.getXAxis(), self.plot3.getXAxis()]
+ )
self.plot1.getXAxis().setScale(self.plot1.getXAxis().LOGARITHMIC)
- self.assertEqual(self.plot1.getXAxis().getScale(), self.plot1.getXAxis().LOGARITHMIC)
- self.assertEqual(self.plot2.getXAxis().getScale(), self.plot1.getXAxis().LOGARITHMIC)
- self.assertEqual(self.plot3.getXAxis().getScale(), self.plot1.getXAxis().LOGARITHMIC)
+ self.assertEqual(
+ self.plot1.getXAxis().getScale(), self.plot1.getXAxis().LOGARITHMIC
+ )
+ self.assertEqual(
+ self.plot2.getXAxis().getScale(), self.plot1.getXAxis().LOGARITHMIC
+ )
+ self.assertEqual(
+ self.plot3.getXAxis().getScale(), self.plot1.getXAxis().LOGARITHMIC
+ )
def testDirection(self):
"""Test direction change"""
- _sync = SyncAxes([self.plot1.getYAxis(), self.plot2.getYAxis(), self.plot3.getYAxis()])
+ _sync = SyncAxes(
+ [self.plot1.getYAxis(), self.plot2.getYAxis(), self.plot3.getYAxis()]
+ )
self.plot1.getYAxis().setInverted(True)
self.assertEqual(self.plot1.getYAxis().isInverted(), True)
self.assertEqual(self.plot2.getYAxis().isInverted(), True)
@@ -160,8 +188,11 @@ class TestAxisSync(TestCaseQt):
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)
+ _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))
@@ -173,8 +204,12 @@ class TestAxisSync(TestCaseQt):
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)
+ _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))
@@ -193,7 +228,9 @@ class TestAxisSync(TestCaseQt):
def testRemoveAxis(self):
"""Test synchronization after construction"""
- sync = SyncAxes([self.plot1.getXAxis(), self.plot2.getXAxis(), self.plot3.getXAxis()])
+ sync = SyncAxes(
+ [self.plot1.getXAxis(), self.plot2.getXAxis(), self.plot3.getXAxis()]
+ )
sync.removeAxis(self.plot3.getXAxis())
self.plot1.getXAxis().setLimits(10, 500)