forked from M-Labs/nac3
standalone: Add np_array tests
This commit is contained in:
parent
6153f94b05
commit
53d44b9595
|
@ -170,6 +170,7 @@ def patch(module):
|
||||||
module.np_full = np.full
|
module.np_full = np.full
|
||||||
module.np_eye = np.eye
|
module.np_eye = np.eye
|
||||||
module.np_identity = np.identity
|
module.np_identity = np.identity
|
||||||
|
module.np_array = np.array
|
||||||
|
|
||||||
# NumPy Math functions
|
# NumPy Math functions
|
||||||
module.np_isnan = np.isnan
|
module.np_isnan = np.isnan
|
||||||
|
|
|
@ -97,6 +97,19 @@ def test_ndarray_eye():
|
||||||
n: ndarray[float, 2] = np_eye(2)
|
n: ndarray[float, 2] = np_eye(2)
|
||||||
output_ndarray_float_2(n)
|
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():
|
def test_ndarray_identity():
|
||||||
n: ndarray[float, 2] = np_identity(2)
|
n: ndarray[float, 2] = np_identity(2)
|
||||||
output_ndarray_float_2(n)
|
output_ndarray_float_2(n)
|
||||||
|
@ -1373,6 +1386,7 @@ def run() -> int32:
|
||||||
test_ndarray_ones()
|
test_ndarray_ones()
|
||||||
test_ndarray_full()
|
test_ndarray_full()
|
||||||
test_ndarray_eye()
|
test_ndarray_eye()
|
||||||
|
test_ndarray_array()
|
||||||
test_ndarray_identity()
|
test_ndarray_identity()
|
||||||
test_ndarray_fill()
|
test_ndarray_fill()
|
||||||
test_ndarray_copy()
|
test_ndarray_copy()
|
||||||
|
|
Loading…
Reference in New Issue