def test_complex64_2d(self): test_input = [[1 + 5j, 2 + 6j, 3 + 7j, 4 + 8j], [9 + 13j, 10 + 14j, 11 + 15j, 12 + 16j]] a = Array.from_numpy( np.array(test_input).astype(np.complex64), dtype.c32) expected = np.array(test_input).astype(np.complex64) np.testing.assert_array_equal(a.to_numpy(), expected)
def test_complex128_3d(self): test_input = [[[1 + 1j, 5 + 5j], [2 + 2j, 6 + 6j]], [[3 + 3j, 7 + 7j], [4 + 4j, 8 + 8j]]] a = Array.from_numpy( np.array(test_input).astype(np.complex128), dtype.c32) expected = np.array(test_input).astype(np.complex128) np.testing.assert_array_equal(a.to_numpy(), expected)
def test_complex64_1d(self): test_input = np.array([1 + 5j, 2 + 6j, 3 + 7j, 4 + 8j]).astype(np.complex64) a = Array.from_numpy(test_input, dtype.c32) expected = np.array(test_input).astype(np.complex64) np.testing.assert_array_equal(a.to_numpy(), expected) np.testing.assert_array_equal(a.dims, np.array([4, 1, 1, 1]))
def test_complex128_4d(self): test_input = [[[[1 + 1j, 9 + 9j], [2 + 2j, 10 + 10j]], [[3 + 3j, 11 + 11j], [4 + 4j, 12 + 12j]]], [[[5 + 5j, 13 + 13j], [6 + 6j, 14 + 14j]], [[7 + 7j, 15 + 15j], [8 + 8j, 16 + 16j]]]] a = Array.from_numpy(np.array(test_input).astype(np.complex128), khiva_type=dtype.c32) expected = np.array(test_input).astype(np.complex128) np.testing.assert_array_equal(a.to_numpy(), expected)
def testFromNumpy(self): test_input = [1, 2, 3, 4] array = Array.from_numpy(np.array(test_input), dtype.s32) np.testing.assert_array_equal(test_input, array.to_numpy())
def testRows(self): a = Array.from_numpy(np.transpose([[1, 2], [3, 4], [5, 6]]), dtype.s32) c = a.get_rows(0, 1) np.testing.assert_array_equal(c.to_numpy(), np.transpose(np.array([[1, 2], [3, 4]])))
def testCols(self): a = Array.from_numpy(np.transpose([[1, 2, 3], [4, 5, 6]]), dtype.s32) c = a.get_cols(0, 1) np.testing.assert_array_equal(c.to_numpy(), np.transpose(np.array([[1, 2], [4, 5]])))
def test_complex128_1d(self): test_input = [1 + 5j, 2 + 6j, 3 + 7j, 4 + 8j] a = Array.from_numpy( np.array(test_input).astype(np.complex128), dtype.c64) expected = np.array(test_input).astype(np.complex128) np.testing.assert_array_equal(a.to_numpy(), expected)