Esempio n. 1
0
    def test_copy(self):
        d = 3
        n = np.array([5, 7, 8])
        l = np.array([[-2., 3.], [-4., 5.], [-6., 9.]])
        GR1 = Grid(d=d, n=n, l=l)

        GR2 = GR1.copy()
        GR2.d = 1
        GR2.n = np.array([5])
        GR2.l = np.array([[-2., 3.]])

        self.assertEqual(
            GR1.d, 3
        )
        np.testing.assert_array_equal(
            GR1.n, np.array([5, 7, 8])
        )
        np.testing.assert_almost_equal(
            GR1.l, np.array([[-2., 3.], [-4., 5.], [-6., 9.]])
        )

        self.assertEqual(
            GR2.d, 1
        )
        np.testing.assert_array_equal(
            GR2.n, np.array([5])
        )
        np.testing.assert_almost_equal(
            GR2.l, np.array([[-2., 3.]])
        )
Esempio n. 2
0
    def test_copy_err(self):
        d = 2
        n1 = np.array([3, 4])
        l1 = np.array([[-2, 4], [-5, 7]])

        GR1 = Grid(d, n1, l1, 'u')

        msg = 'Invalid dimension for number of points (n).'
        with self.assertRaises(IndexError) as ctx:
            GR2 = GR1.copy(d=1)
        self.assertIn(msg, str(ctx.exception))
Esempio n. 3
0
    def test_copy(self):
        d = 2
        n1 = np.array([3, 4])
        l1 = np.array([[-2, 4], [-5, 7]])
        n2 = [4, 5]
        l2 = np.array([[-3, 5], [-6, 8]])

        GR1 = Grid(d, n1, l1, 'u')
        GR2 = GR1.copy(n=n2, l=l2)

        np.testing.assert_array_equal(GR1.n, n1)
        np.testing.assert_array_equal(GR2.n, n2)

        np.testing.assert_array_equal(GR1.l, l1)
        np.testing.assert_array_equal(GR2.l, l2)