add from_buffer tests
This commit is contained in:
parent
663a7d2fe0
commit
c501569dd7
3 changed files with 31 additions and 1 deletions
2
build.sh
2
build.sh
|
|
@ -44,7 +44,7 @@ make -C micropython/ports/unix -j${NPROC} axtls
|
||||||
make -C micropython/ports/unix -j${NPROC} USER_C_MODULES="${HERE}" DEBUG=1 STRIP=: MICROPY_PY_FFI=0 MICROPY_PY_BTREE=0
|
make -C micropython/ports/unix -j${NPROC} USER_C_MODULES="${HERE}" DEBUG=1 STRIP=: MICROPY_PY_FFI=0 MICROPY_PY_BTREE=0
|
||||||
|
|
||||||
|
|
||||||
for dir in "numpy" "common"
|
for dir in "numpy" "common" "utils"
|
||||||
do
|
do
|
||||||
if ! env MICROPY_MICROPYTHON=micropython/ports/unix/micropython ./run-tests -d tests/"$dir"; then
|
if ! env MICROPY_MICROPYTHON=micropython/ports/unix/micropython ./run-tests -d tests/"$dir"; then
|
||||||
for exp in *.exp; do
|
for exp in *.exp; do
|
||||||
|
|
|
||||||
22
tests/utils/from_buffer.py
Normal file
22
tests/utils/from_buffer.py
Normal file
|
|
@ -0,0 +1,22 @@
|
||||||
|
from ulab import numpy as np
|
||||||
|
from ulab import utils
|
||||||
|
|
||||||
|
a = bytearray([1, 0, 0, 1, 0, 255, 255, 255])
|
||||||
|
print(utils.from_uint16_buffer(a))
|
||||||
|
a = bytearray([1, 0, 0, 1, 0, 255, 255, 255])
|
||||||
|
print(utils.from_int16_buffer(a))
|
||||||
|
|
||||||
|
a = bytearray([1, 0, 0, 1, 0, 255, 255, 255])
|
||||||
|
print(utils.from_uint32_buffer(a))
|
||||||
|
a = bytearray([1, 0, 0, 1, 0, 255, 255, 255])
|
||||||
|
print(utils.from_int32_buffer(a))
|
||||||
|
|
||||||
|
a = bytearray([1, 0, 0, 1, 0, 0, 255, 255])
|
||||||
|
print(utils.from_uint32_buffer(a))
|
||||||
|
a = bytearray([1, 0, 0, 1, 0, 0, 255, 255])
|
||||||
|
print(utils.from_int32_buffer(a))
|
||||||
|
|
||||||
|
a = bytearray([1, 0, 0, 0, 0, 0, 0, 1])
|
||||||
|
print(utils.from_uint32_buffer(a))
|
||||||
|
a = bytearray([1, 0, 0, 0, 0, 0, 0, 1])
|
||||||
|
print(utils.from_int32_buffer(a))
|
||||||
8
tests/utils/from_buffer.py.exp
Normal file
8
tests/utils/from_buffer.py.exp
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
array([1.0, 256.0, 65280.0, 65535.00000000001], dtype=float64)
|
||||||
|
array([1.0, 256.0, -256.0, -1.0], dtype=float64)
|
||||||
|
array([16777217.0, 4294967040.0], dtype=float64)
|
||||||
|
array([16777217.0, -256.0], dtype=float64)
|
||||||
|
array([16777217.0, 4294901760.0], dtype=float64)
|
||||||
|
array([16777217.0, -65536.0], dtype=float64)
|
||||||
|
array([1.0, 16777216.0], dtype=float64)
|
||||||
|
array([1.0, 16777216.0], dtype=float64)
|
||||||
Loading…
Reference in a new issue