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

« back to all changes in this revision

Viewing changes to chaco/shell/tests/make_data_sources_test_case.py

  • Committer: Package Import Robot
  • Author(s): Andrew Starr-Bochicchio
  • Date: 2014-06-01 17:04:08 UTC
  • mfrom: (7.2.5 sid)
  • Revision ID: package-import@ubuntu.com-20140601170408-m86xvdjd83a4qon0
Tags: 4.4.1-1ubuntu1
* Merge from Debian unstable. Remaining Ubuntu changes:
 - Let the binary-predeb target work on the usr/lib/python* directory
   as we don't have usr/share/pyshared anymore.

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 chaco.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