plot_utils: make xlim and ylim consistent and accept strings as well as tuples
before xlim = None was different than ylim = None. Discard the None
and just make them accept strings that describe their purpose.
diff --git a/tests/test_plot_utils.py b/tests/test_plot_utils.py
index d774118..361477c 100644
--- a/tests/test_plot_utils.py
+++ b/tests/test_plot_utils.py
@@ -19,6 +19,51 @@
self.assertEquals(plot_utils.normalize_title("Foo", ""), "Foo")
self.assertEquals(plot_utils.normalize_title("Foo", "Bar"), "Bar - Foo")
+ def test_set_lim(self):
+ """Test set_lim()"""
+
+ class GetSet(object):
+ def __init__(self):
+ self.min = 1
+ self.max = 2
+
+ def get(self):
+ return (self.min, self.max)
+
+ def set(self, minimum, maximum):
+ self.min = minimum
+ self.max = maximum
+
+ gs = GetSet()
+
+ plot_utils.set_lim("default", gs.get, gs.set)
+ self.assertEquals(gs.min, 1)
+ self.assertEquals(gs.max, 2)
+
+ plot_utils.set_lim("range", gs.get, gs.set)
+ self.assertEquals(gs.min, 0.9)
+ self.assertEquals(gs.max, 2.1)
+
+ plot_utils.set_lim((0, 100), gs.get, gs.set)
+ self.assertEquals(gs.min, 0)
+ self.assertEquals(gs.max, 100)
+
+ def test_set_ylim(self):
+ """Test that set_ylim() doesn't bomb"""
+
+ ax = plot_utils.pre_plot_setup()
+
+ plot_utils.set_ylim(ax, "default")
+ plot_utils.set_ylim(ax, (0, 5))
+
+ def test_set_xlim(self):
+ """Test that set_xlim() doesn't bomb"""
+
+ ax = plot_utils.pre_plot_setup()
+
+ plot_utils.set_xlim(ax, "default")
+ plot_utils.set_xlim(ax, (0, 5))
+
def test_post_plot_setup(self):
"""Test that post_plot_setup() doesn't bomb"""
@@ -27,8 +72,10 @@
plot_utils.post_plot_setup(ax)
plot_utils.post_plot_setup(ax, title="Foo")
plot_utils.post_plot_setup(ax, ylim=(0, 72))
+ plot_utils.post_plot_setup(ax, ylim="range")
plot_utils.post_plot_setup(ax, xlabel="Bar")
plot_utils.post_plot_setup(ax, xlim=(0, 100))
+ plot_utils.post_plot_setup(ax, xlim="default")
class TestPlotUtilsNeedTrace(TestThermalBase):
def test_plot_allfreqs(self):