forked from M-Labs/nac3
1
0
Fork 0

standalone: add test_ndarray_subscript_assignment

This commit is contained in:
lyken 2024-08-21 16:16:09 +08:00
parent c582ffe53d
commit 117110dd91
No known key found for this signature in database
GPG Key ID: 3BD5FC6AC8325DD8
1 changed files with 22 additions and 0 deletions

View File

@ -199,6 +199,27 @@ def test_ndarray_nd_idx():
output_float64(x[1, 0])
output_float64(x[1, 1])
def test_ndarray_subscript_assignment():
xs = np_array([[11111.0, 2.0, 3.0], [4.0, 5.0, 6.0], [7.0, 8.0, 99999.0]])
output_ndarray_float_2(xs)
output_int32(np_shape(xs[1:, 1::])[0])
output_int32(np_shape(xs[1:, 1::])[1])
xs[1:, 1::] = 77.0
output_ndarray_float_2(xs)
xs[0, -1] = 88.0
output_ndarray_float_2(xs)
ys = np_transpose(xs)[1::-1]
ys[0] = np_array([44.0, 55.0, 66.0])
output_ndarray_float_2(xs)
output_ndarray_float_2(ys)
zs = np_reshape(xs, (-1,))
zs[2:5] = np_array([1000.0, 2000.0, 3000.0])
output_ndarray_float_2(xs)
def test_ndarray_add():
x = np_identity(2)
y = x + np_ones([2, 2])
@ -1641,6 +1662,7 @@ def run() -> int32:
test_ndarray_neg_idx()
test_ndarray_slices()
test_ndarray_nd_idx()
test_ndarray_subscript_assignment()
test_ndarray_add()
test_ndarray_add_broadcast()