/usr/lib/python2.7/dist-packages/chaco/tests/linearmapper_test_case.py is in python-chaco 4.4.1-1.2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | import unittest
from numpy import array
from numpy.testing import assert_equal
from chaco.api import ArrayDataSource, DataRange1D, LinearMapper
class LinearMapperTestCase(unittest.TestCase):
def test_basic(self):
ary = array([5.0, 6.0, 7.0, 8.0, 9.0, 10.0])
ds = ArrayDataSource(ary)
r = DataRange1D(ds)
mapper = LinearMapper(range=r, low_pos=50, high_pos=100)
result = mapper.map_screen(ary)
assert_equal(result , array([50, 60, 70, 80, 90, 100]))
return
def test_reversed(self):
ary = array([5.0, 6.0, 7.0, 8.0, 9.0, 10.0])
ds = ArrayDataSource(ary)
r = DataRange1D(ds)
mapper = LinearMapper(range=r, low_pos=100, high_pos=0)
result = mapper.map_screen(ary)
assert_equal(result , array([100, 80, 60, 40, 20, 0]))
return
if __name__ == '__main__':
import nose
nose.run()
|