~ubuntu-branches/ubuntu/utopic/python-chaco/utopic

« back to all changes in this revision

Viewing changes to enthought/chaco2/shell/tests/make_data_sources_test_case.py

  • Committer: Bazaar Package Importer
  • Author(s): Varun Hiremath
  • Date: 2011-04-06 19:03:54 UTC
  • mfrom: (7.2.2 sid)
  • Revision ID: james.westby@ubuntu.com-20110406190354-rwd55l2ezjecfo41
Tags: 3.4.0-2
d/rules: fix pyshared directory path (Closes: #621116)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
 
2
 
import unittest
3
 
 
4
 
import numpy as np
5
 
from numpy.testing.utils import assert_almost_equal
6
 
from enthought.chaco2.shell.plot_maker import make_data_sources
7
 
 
8
 
class MakeDataSourcesTestCase(unittest.TestCase):
9
 
    
10
 
    def test_1D_single(self):
11
 
        session = None
12
 
        ary = np.array([3.0, 2.1, 1.3, 1.8, 5.7])
13
 
        sources = make_data_sources(session, "none", ary)
14
 
        assert_almost_equal(sources[0][0].get_data(), np.arange(len(ary)))
15
 
        assert_almost_equal(sources[0][1].get_data(), ary)
16
 
        return
17
 
    
18
 
    def test_1d_multiple(self):
19
 
        session = None
20
 
        index = np.arange(-np.pi, np.pi, np.pi/30.0)
21
 
        s = np.sin(index)
22
 
        c = np.cos(index)
23
 
        t = np.tan(index)
24
 
        sources = make_data_sources(session, "ascending", index, s, c, t)
25
 
        assert_almost_equal(sources[0][0].get_data(), index)
26
 
        self.assert_(sources[0][0] == sources[1][0])
27
 
        self.assert_(sources[0][0] == sources[2][0])
28
 
        assert_almost_equal(sources[0][1].get_data(), s)
29
 
        assert_almost_equal(sources[1][1].get_data(), c)
30
 
        assert_almost_equal(sources[2][1].get_data(), t)
31
 
        return
32
 
        
33
 
 
34
 
if __name__ == "__main__":
35
 
    unittest.main()
36
 
 
37
 
# EOF