From ef57cad1a3b5c5e09d534ae65dfaf13de682ae84 Mon Sep 17 00:00:00 2001 From: David Nadlinger Date: Tue, 28 Jul 2020 01:17:22 +0100 Subject: [PATCH] compiler: Test ndarray element assignment --- artiq/test/lit/integration/array.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/artiq/test/lit/integration/array.py b/artiq/test/lit/integration/array.py index aa4001fb6..05785889d 100644 --- a/artiq/test/lit/integration/array.py +++ b/artiq/test/lit/integration/array.py @@ -24,15 +24,24 @@ assert [x for x in array_of_lists] == list_of_lists matrix = array([[1.0, 2.0, 3.0], [4.0, 5.0, 6.0]]) assert len(matrix) == 2 assert matrix.shape == (2, 3) +# FIXME: Need to decide on a solution for array comparisons — +# NumPy returns an array of bools! +# assert [x for x in matrix] == [array([1.0, 2.0, 3.0]), array([4.0, 5.0, 6.0])] assert matrix[0][0] == 1.0 assert matrix[0][1] == 2.0 assert matrix[0][2] == 3.0 assert matrix[1][0] == 4.0 assert matrix[1][1] == 5.0 assert matrix[1][2] == 6.0 -# FIXME: Need to decide on a solution for array comparisons — -# NumPy returns an array of bools! -# assert [x for x in matrix] == [array([1.0, 2.0, 3.0]), array([4.0, 5.0, 6.0])] + +matrix[0][0] = 7.0 +matrix[1][1] = 8.0 +assert matrix[0][0] == 7.0 +assert matrix[0][1] == 2.0 +assert matrix[0][2] == 3.0 +assert matrix[1][0] == 4.0 +assert matrix[1][1] == 8.0 +assert matrix[1][2] == 6.0 three_tensor = array([[[1.0, 2.0, 3.0], [4.0, 5.0, 6.0]]]) assert len(three_tensor) == 1