1
0
forked from M-Labs/nac3

standalone: Add np_array tests

This commit is contained in:
David Mak 2024-06-11 15:30:57 +08:00
parent 6153f94b05
commit 53d44b9595
2 changed files with 15 additions and 0 deletions

View File

@ -170,6 +170,7 @@ def patch(module):
module.np_full = np.full
module.np_eye = np.eye
module.np_identity = np.identity
module.np_array = np.array
# NumPy Math functions
module.np_isnan = np.isnan

View File

@ -97,6 +97,19 @@ def test_ndarray_eye():
n: ndarray[float, 2] = np_eye(2)
output_ndarray_float_2(n)
def test_ndarray_array():
n1: ndarray[float, 1] = np_array([1.0, 2.0, 3.0])
output_ndarray_float_1(n1)
n1to2: ndarray[float, 2] = np_array([1.0, 2.0, 3.0], ndmin=2)
output_ndarray_float_2(n1to2)
n2: ndarray[float, 2] = np_array([[1.0, 2.0, 3.0], [4.0, 5.0, 6.0]])
output_ndarray_float_2(n2)
# Copy
n2_cpy: ndarray[float, 2] = np_array(n2, copy=False)
n2_cpy.fill(0.0)
output_ndarray_float_2(n2_cpy)
def test_ndarray_identity():
n: ndarray[float, 2] = np_identity(2)
output_ndarray_float_2(n)
@ -1373,6 +1386,7 @@ def run() -> int32:
test_ndarray_ones()
test_ndarray_full()
test_ndarray_eye()
test_ndarray_array()
test_ndarray_identity()
test_ndarray_fill()
test_ndarray_copy()