source: tags/casa3.2.0asap/test/test_plotter.py@ 2956

Last change on this file since 2956 was 1839, checked in by Malte Marquarding, 14 years ago

initial check-in of 'nose' based test for the asapplotter

File size: 1.9 KB
Line 
1import sys
2from asap import scantable, selector, rcParams, asapplotter
3rcParams["verbose"] = False
4rcParams["plotter.gui"] = False
5from nose.tools import raises
6
7# necessary for python < 2.6 otherwise it is in itertools
8def permutations(iterable, r=None):
9 # permutations('ABCD', 2) --> AB AC AD BA BC BD CA CB CD DA DB DC
10 # permutations(range(3)) --> 012 021 102 120 201 210
11 pool = tuple(iterable)
12 n = len(pool)
13 r = n if r is None else r
14 if r > n:
15 return
16 indices = range(n)
17 cycles = range(n, n-r, -1)
18 yield tuple(pool[i] for i in indices[:r])
19 while n:
20 for i in reversed(range(r)):
21 cycles[i] -= 1
22 if cycles[i] == 0:
23 indices[i:] = indices[i+1:] + indices[i:i+1]
24 cycles[i] = n - i
25 else:
26 j = cycles[i]
27 indices[i], indices[-j] = indices[-j], indices[i]
28 yield tuple(pool[i] for i in indices[:r])
29 break
30 else:
31 return
32
33
34class TestPlotter(object):
35
36 @classmethod
37 def setupClass(self):
38 self.plotter = asapplotter(False)
39 st = scantable("data/MOPS.rpf", average=True)
40 self.st = st.auto_quotient()
41
42
43 def test_plot(self):
44 self.plotter.plot(self.st)
45
46 def test_histogram(self):
47 self.plotter.plot(self.st)
48 self.plotter.set_histogram(hist=True, linewidth=2)
49 self.plotter.set_histogram(hist=False)
50
51 def switch_mode(self, args):
52 self.plotter.set_mode(*args)
53 assert self.plotter._panelling, args[0]
54 assert self.plotter._stacking, args[1]
55
56 # generator for set_mode arguments
57 def test_set_mode(self):
58 combis = permutations('stbpi', 2)
59 for mode in combis:
60 yield self.switch_mode, mode
61
62 @raises(TypeError)
63 def test_fail_set_mode(self):
64 self.plotter.set_mode('x', 'y')
65
Note: See TracBrowser for help on using the repository browser.