Exemplo n.º 1
0
    def test_pow(self):
        x = np.arange(4)
        y = np.arange(4) + 5
        d = XYDataObject(x, y)

        d_out = d**10  # Test multiplying scalar
        self.assertTrue(np.array_equal(d.y**10, d_out.y))

        d_out = d**y[::-1]  # Test multiplying array
        self.assertTrue(np.array_equal(d.y**y[::-1], d_out.y))

        d_out = d**XYDataObject(x, y**2)  # Test multiplying another DataObject
        self.assertTrue(np.array_equal(d.y**(y**2), d_out.y))
Exemplo n.º 2
0
    def test_sub(self):
        x = np.arange(4)
        y = np.arange(4) + 5
        d = XYDataObject(x, y)

        d_out = d - 10  # Test subtracting scalar
        self.assertTrue(np.array_equal(d.y - 10, d_out.y))

        d_out = d - y[::-1]  # Test subtracting array
        self.assertTrue(np.array_equal(d.y - y[::-1], d_out.y))

        d_out = d - XYDataObject(x, y**2)  # Test adding another DataObject
        self.assertTrue(np.array_equal(d.y - y**2, d_out.y))
Exemplo n.º 3
0
    def test_floordiv(self):
        x = np.arange(4)
        y = np.arange(4) + 5
        d = XYDataObject(x, y)

        d_out = d // 10
        self.assertTrue(np.array_equal(d.y // 10, d_out.y))

        d_out = d // y[::-1]
        self.assertTrue(np.array_equal(d.y // y[::-1], d_out.y))

        d_out = d // XYDataObject(x, y**2)
        self.assertTrue(np.array_equal(d.y // y**2, d_out.y))
Exemplo n.º 4
0
    def test_inputtype(self):
        with self.assertRaises(TypeError):
            x = 'test_string'
            y = [1, 2, 3, 4]
            XYDataObject(x, y)

        with self.assertRaises(ValueError):
            x = [1, 2, 3, 4, 5]
            y = [1, 2, 3, 4]
            XYDataObject(x, y)

        with self.assertRaises(ValueError):
            x = np.arange(10).reshape(5)
            y = np.arange(5)
            XYDataObject(x, y)
Exemplo n.º 5
0
    def test_ipow(self):
        x = np.arange(4)
        y = (np.arange(4) + 5)
        d = XYDataObject(x, y)
        d **= 3

        self.assertTrue(np.array_equal(d.y, y**3))
Exemplo n.º 6
0
    def test_ifloordiv(self):
        x = np.arange(4)
        y = (np.arange(4) + 5).astype('float')
        d = XYDataObject(x, y)
        d //= 3

        self.assertTrue(np.array_equal(d.y, y // 3))
Exemplo n.º 7
0
    def test_iadd(self):
        x = np.arange(4)
        y = (np.arange(4) + 5)
        d = XYDataObject(x, y)
        d += 3

        self.assertTrue(np.array_equal(d.y, y + 3))
Exemplo n.º 8
0
    def test_isub(self):
        x = np.arange(4)
        y = (np.arange(4) + 5)
        d = XYDataObject(x, y)
        d -= 3

        self.assertTrue(np.array_equal(d.y, y - 3))
Exemplo n.º 9
0
from atomicplot.data import XYDataObject
from atomicplot.plot import MatPlot


d = XYDataObject([1,2,3], [4,5,6])
mp = MatPlot()

mp += d

d.plot.updated = True
d.plot.updated = True

print(d.plot._y_dict)
print(d.plot._x_dict)

d.plot.norm = True

print(d.plot._y_dict)
print(d.plot._x_dict)
Exemplo n.º 10
0
 def test_abs(self):
     x = np.arange(4)
     y = np.arange(4) - 3
     d = XYDataObject(x, y)
     d_out = abs(d)
     self.assertTrue(np.array_equal(np.absolute(d.y), d_out.y))
Exemplo n.º 11
0
 def test_neg(self):
     x = np.arange(4)
     y = np.arange(4) + 5
     d = XYDataObject(x, y)
     d_out = -d
     self.assertTrue(np.array_equal(-1 * d.y, d_out.y))