Ejemplo n.º 1
0
    def test_constant_values(self):
        r = DataRange2D()
        ds = PointDataSource(array([[5.0, 5.0]]), sort_order="none")
        r.add(ds)
        # A constant value > 1.0, by default, gets a range that brackets
        # it to the nearest power of ten above and below
        assert_ary_(r.low, array([1.0, 1.0]))
        assert_ary_(r.high, array([10.0, 10.0]))

        r.remove(ds)
        ds = PointDataSource(array([[31.4, 9.7]]))
        r.add(ds)

        assert_ary_(r.low, array([10.0, 1.0]))
        assert_ary_(r.high, array([100.0, 10.0]))

        r.remove(ds)
        ds = PointDataSource(array([[0.125, 0.125]]))
        r.add(ds)
        assert_ary_(r.low, array([0.0, 0.0]))
        assert_ary_(r.high, array([0.25, 0.25]))

        r.remove(ds)
        ds = PointDataSource(array([[-0.125, -0.125]]))
        r.add(ds)
        assert_ary_(r.low, array([-0.25, -0.25]))
        assert_ary_(r.high, array([0.0, 0.0]))
        return
Ejemplo n.º 2
0
 def test_multi_source(self):
     x = arange(10.)
     y = arange(0., 100., 10.)
     foo = transpose(array([x, y]))
     bar = transpose(array([y, x]))
     ds1 = PointDataSource(foo)
     ds2 = PointDataSource(bar)
     r = DataRange2D(ds1, ds2)
     assert_ary_(r.low, [0.0, 0.0])
     assert_ary_(r.high, [90., 90.])
     return
Ejemplo n.º 3
0
    def test_single_source(self):
        r = DataRange2D()
        x = arange(10.)
        y = arange(0., 100., 10.)
        ds = PointDataSource(transpose(array([x, y])), sort_order="none")
        r.add(ds)
        assert_ary_(r.low, array([0., 0.]))
        assert_ary_(r.high, array([9.0, 90.0]))

        r.low = [3.0, 30.0]
        r.high = [6.0, 60.0]
        assert_ary_(r.low_setting, array([3.0, 30.0]))
        assert_ary_(r.high_setting, array([6.0, 60.0]))
        assert_ary_(r.low, array([3.0, 30.0]))
        assert_ary_(r.high, array([6.0, 60.0]))

        r.refresh()
        assert_ary_(r.low_setting, array([3.0, 30.0]))
        assert_ary_(r.high_setting, array([6.0, 60.0]))
        assert_ary_(r.low, array([3.0, 30.0]))
        assert_ary_(r.high, array([6.0, 60.0]))

        r.low = ('auto', 'auto')
        self.assertTrue(r.low_setting == ('auto', 'auto'))
        assert_ary_(r.low, array([0.0, 0.0]))
        return
Ejemplo n.º 4
0
 def test_bounds(self):
     myarray = self.create_array()
     pd = PointDataSource(myarray)
     self.assertEqual(pd.get_bounds(), ((0, 0), (9, 90)))
Ejemplo n.º 5
0
 def test_basic_set_get(self):
     myarray = self.create_array()
     pd = PointDataSource(myarray)
     self.assertTrue(allclose(myarray, pd._data))
     self.assertTrue(pd.value_dimension == "point")
Ejemplo n.º 6
0
 def test_bounds(self):
     myarray = self.create_array()
     pd = PointDataSource(myarray)
     self.assertEqual(pd.get_bounds(), ((0, 0), (9, 90)))
     return