Esempio n. 1
0
 def test_abs(self):
     x, y = initVariablesADI(np.array([[5, -2]]).T, np.array([[3]]).T)
     z1 = (x*y).abs()
     assert np.array_equal(z1.val, np.array([[15, 6]]).T)
     assert (z1.jac[0] - sps.diags([3, -3], 0)).nnz == 0
     assert np.array_equal(z1.jac[1].toarray(), np.array([[5], [2]]))
     z2 = npad.abs(x*y)
     assert np.array_equal(z2.val, np.array([[15, 6]]).T)
     assert (z2.jac[0] - sps.diags([3, -3], 0)).nnz == 0
     assert np.array_equal(z2.jac[1].toarray(), np.array([[5], [2]]))
Esempio n. 2
0
 def test_vec_vec(self):
     a, b = np.array([[1,-2]]), np.array([[3,4]])
     assert np.array_equal(npad.tile(a, (3,2)), np.tile(a, (3,2)))
     assert np.array_equal(npad.sign(a), np.sign(a))
     assert np.array_equal(npad.abs(a), np.abs(a))