micropython-ulab/tests/2d/numpy/delete.py
yyyz 7a9370612f
fix the np.delete bug (#653)
* fix the `np.delete` bug

* fix the `np.delete` bug, add unittest code

* increment the version number and update the change log

* update the expected file `delete.py.exp`
2023-12-25 10:56:16 +01:00

28 lines
777 B
Python

try:
from ulab import numpy as np
except:
import numpy as np
np.set_printoptions(threshold=200)
dtypes = (np.uint8, np.int8, np.uint16, np.int16, np.float)
for dtype in dtypes:
a = np.array(range(25), dtype=dtype).reshape((5,5))
print(np.delete(a, [1, 2], axis=0))
print(np.delete(a, [1, 2], axis=1))
print(np.delete(a, [], axis=1))
print(np.delete(a, [1, 5, 10]))
print(np.delete(a, []))
for dtype in dtypes:
a = np.array(range(25), dtype=dtype).reshape((5,5))
print(np.delete(a, 2, axis=0))
print(np.delete(a, 2, axis=1))
print(np.delete(a, 2))
for dtype in dtypes:
a = np.array(range(25), dtype=dtype).reshape((5,5))
print(np.delete(a, -3, axis=0))
print(np.delete(a, -3, axis=1))
print(np.delete(a, -3))