def test_copy_vector(self): a = Ad_array(np.ones((3, 1)), np.ones((3, 1))) b = a.copy() self.assertTrue(np.allclose(a.val, b.val)) self.assertTrue(np.allclose(a.jac, b.jac)) a.val[0] = 3 a.jac[2] = 4 self.assertTrue(np.allclose(b.val, np.ones((3, 1)))) self.assertTrue(np.allclose(b.jac, np.ones((3, 1))))
def test_copy_scalar(self): a = Ad_array(1, 0) b = a.copy() self.assertTrue(a.val == b.val) self.assertTrue(a.jac == b.jac) a.val = 2 a.jac = 3 self.assertTrue(b.val == 1) self.assertTrue(b.jac == 0)