From 23b2fee4e799e2ac164b90a91b902a7cf9097f48 Mon Sep 17 00:00:00 2001 From: David Mak Date: Thu, 30 May 2024 16:08:35 +0800 Subject: [PATCH] standalone: Add test case for ndarray slicing --- nac3standalone/demo/src/ndarray.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/nac3standalone/demo/src/ndarray.py b/nac3standalone/demo/src/ndarray.py index 91982429..fc60e04e 100644 --- a/nac3standalone/demo/src/ndarray.py +++ b/nac3standalone/demo/src/ndarray.py @@ -121,6 +121,22 @@ def test_ndarray_neg_idx(): for j in range(-1, -3, -1): output_float64(x[i][j]) +def test_ndarray_slices(): + x = np_identity(3) + output_ndarray_float_2(x) + + x_identity = x[::] + output_ndarray_float_2(x_identity) + + x02 = x[0::2] + output_ndarray_float_2(x02) + + x_mirror = x[::-1] + output_ndarray_float_2(x_mirror) + + x2 = x[0::2, 0::2] + output_ndarray_float_2(x2) + def test_ndarray_add(): x = np_identity(2) y = x + np_ones([2, 2]) @@ -1360,7 +1376,10 @@ def run() -> int32: test_ndarray_identity() test_ndarray_fill() test_ndarray_copy() + test_ndarray_neg_idx() + test_ndarray_slices() + test_ndarray_add() test_ndarray_add_broadcast() test_ndarray_add_broadcast_lhs_scalar()