Implement ndarray.array #412

Merged
sb10q merged 1 commits from enhance/issue-149-ndarray/numpy-array-func into master 2024-08-17 17:37:21 +08:00
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()