~ubuntu-branches/ubuntu/trusty/python-chaco/trusty-proposed

« back to all changes in this revision

Viewing changes to enthought/chaco2/tests/instantiation_order_test_case.py

  • Committer: Bazaar Package Importer
  • Author(s): Varun Hiremath
  • Date: 2010-02-28 14:05:25 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20100228140525-1eo43ddoakb2j3j9
Tags: 3.3.0-1
* New upstream release
* Switch to source format 3.0 (quilt)
* Bump Standards-Version to 3.8.4
* Remove transition package: python-enthought-chaco2

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
"""
2
 
Tests that various plot and data objects can be instantiated, assigned, and
3
 
re-assigned in any order.
4
 
"""
5
 
 
6
 
import unittest
7
 
 
8
 
from numpy import array
9
 
from enthought.chaco2.api import ArrayDataSource, DataRange1D, \
10
 
                                 LinearMapper
11
 
 
12
 
class DataPipelineTestCase(unittest.TestCase):
13
 
    def test_piecewise_construction(self):
14
 
        ary = array([1,2,3,4,5,6,7])
15
 
        ds = ArrayDataSource()
16
 
        ds.set_data(ary)
17
 
        r = DataRange1D()
18
 
        r.add(ds)
19
 
        self.assert_(r.low_setting == "auto")
20
 
        self.assert_(r.high_setting == "auto")
21
 
        self.assert_(r.low == 1)
22
 
        self.assert_(r.high == 7)
23
 
        
24
 
        mapper = LinearMapper()
25
 
        mapper.range = r
26
 
        mapper.low_pos = 1.0
27
 
        mapper.high_pos = 7.0
28
 
        screen_pts = mapper.map_screen(array([1,3,7]))
29
 
        self.assert_(tuple(screen_pts) == (1.0, 3.0, 7.0))
30
 
        return
31
 
 
32
 
    def test_reverse_construction(self):
33
 
        mapper = LinearMapper()
34
 
        r = DataRange1D()
35
 
        ds = ArrayDataSource()
36
 
        ary = array([1,2,3,4,5,6,7])
37
 
        
38
 
        mapper.range = r
39
 
        mapper.low_pos = 1.0
40
 
        mapper.high_pos = 7.0
41
 
        r.add(ds)
42
 
        ds.set_data(ary)
43
 
        
44
 
        self.assert_(r.low == 1)
45
 
        self.assert_(r.high == 7)
46
 
        screen_pts = mapper.map_screen(array([1,3,7]))
47
 
        self.assert_(tuple(screen_pts) == (1.0, 3.0, 7.0))
48
 
        return
49
 
 
50
 
 
51
 
if __name__ == '__main__':
52
 
    import nose
53
 
    nose.run()