diff options
| author | Raghuram Subramani <raghus2247@gmail.com> | 2022-06-19 19:47:51 +0530 |
|---|---|---|
| committer | Raghuram Subramani <raghus2247@gmail.com> | 2022-06-19 19:47:51 +0530 |
| commit | 4fd287655a72b9aea14cdac715ad5b90ed082ed2 (patch) | |
| tree | 65d393bc0e699dd12d05b29ba568e04cea666207 /circuitpython/extmod/ulab/tests/2d/numpy/methods.py | |
| parent | 0150f70ce9c39e9e6dd878766c0620c85e47bed0 (diff) | |
add circuitpython code
Diffstat (limited to '')
| -rw-r--r-- | circuitpython/extmod/ulab/tests/2d/numpy/methods.py | 51 | ||||
| -rw-r--r-- | circuitpython/extmod/ulab/tests/2d/numpy/methods.py.exp | 35 |
2 files changed, 86 insertions, 0 deletions
diff --git a/circuitpython/extmod/ulab/tests/2d/numpy/methods.py b/circuitpython/extmod/ulab/tests/2d/numpy/methods.py new file mode 100644 index 0000000..0fa7912 --- /dev/null +++ b/circuitpython/extmod/ulab/tests/2d/numpy/methods.py @@ -0,0 +1,51 @@ +try: + from ulab import numpy as np +except ImportError: + import numpy as np + +a = np.array([1, 2, 3, 4], dtype=np.int8) +b = a.copy() +print(b) +a = np.array([[1,2,3],[4,5,6],[7,8,9]], dtype=np.int16) +b = a.copy() +print(b) +a = np.array([[1,2,3],[4,5,6],[7,8,9]], dtype=np.float) +b = a.copy() +print(b) +print(a.dtype) +print(a.flatten()) +print(np.array([1,2,3], dtype=np.uint8).itemsize) +print(np.array([1,2,3], dtype=np.uint16).itemsize) +print(np.array([1,2,3], dtype=np.int8).itemsize) +print(np.array([1,2,3], dtype=np.int16).itemsize) +print(np.array([1,2,3], dtype=np.float).itemsize) +print(np.array([1,2,3], dtype=np.float).shape) +print(np.array([[1],[2],[3]], dtype=np.float).shape) +print(np.array([[1],[2],[3]], dtype=np.float).reshape((1,3))) +print(np.array([[1],[2],[3]]).size) +print(np.array([1,2,3], dtype=np.float).size) +print(np.array([1,2,3], dtype=np.uint8).tobytes()) +print(np.array([1,2,3], dtype=np.int8).tobytes()) +print(np.array([1,2,3], dtype=np.float).transpose().shape) +print(np.array([[1],[2],[3]], dtype=np.float).transpose().shape) +a = np.array([1, 2, 3, 4, 5, 6], dtype=np.uint8) +b = a.byteswap(inplace=False) +print(a) +print(b) +c = a.byteswap(inplace=True) +print(a) +print(c) +a = np.array([1, 2, 3, 4, 5, 6], dtype=np.uint16) +b = a.byteswap(inplace=False) +print(a) +print(b) +c = a.byteswap(inplace=True) +print(a) +print(c) +a = np.array([1, 2, 3, 4, 5, 6], dtype=np.float) +b = a.byteswap(inplace=False) +print(a) +print(b) +c = a.byteswap(inplace=True) +print(a) +print(c) diff --git a/circuitpython/extmod/ulab/tests/2d/numpy/methods.py.exp b/circuitpython/extmod/ulab/tests/2d/numpy/methods.py.exp new file mode 100644 index 0000000..fb035da --- /dev/null +++ b/circuitpython/extmod/ulab/tests/2d/numpy/methods.py.exp @@ -0,0 +1,35 @@ +array([1, 2, 3, 4], dtype=int8) +array([[1, 2, 3], + [4, 5, 6], + [7, 8, 9]], dtype=int16) +array([[1.0, 2.0, 3.0], + [4.0, 5.0, 6.0], + [7.0, 8.0, 9.0]], dtype=float64) +100 +array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0], dtype=float64) +1 +2 +1 +2 +8 +(3,) +(3, 1) +array([[1.0, 2.0, 3.0]], dtype=float64) +3 +3 +bytearray(b'\x01\x02\x03') +bytearray(b'\x01\x02\x03') +(3,) +(1, 3) +array([1, 2, 3, 4, 5, 6], dtype=uint8) +array([1, 2, 3, 4, 5, 6], dtype=uint8) +array([1, 2, 3, 4, 5, 6], dtype=uint8) +array([1, 2, 3, 4, 5, 6], dtype=uint8) +array([1, 2, 3, 4, 5, 6], dtype=uint16) +array([256, 512, 768, 1024, 1280, 1536], dtype=uint16) +array([256, 512, 768, 1024, 1280, 1536], dtype=uint16) +array([256, 512, 768, 1024, 1280, 1536], dtype=uint16) +array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0], dtype=float64) +array([3.038651941617419e-319, 3.162020133383978e-322, 1.043466644016713e-320, 2.055313086699586e-320, 2.561236308041022e-320, 3.067159529382458e-320], dtype=float64) +array([3.038651941617419e-319, 3.162020133383978e-322, 1.043466644016713e-320, 2.055313086699586e-320, 2.561236308041022e-320, 3.067159529382458e-320], dtype=float64) +array([3.038651941617419e-319, 3.162020133383978e-322, 1.043466644016713e-320, 2.055313086699586e-320, 2.561236308041022e-320, 3.067159529382458e-320], dtype=float64) |
