add from_buffer tests

This commit is contained in:
Zoltán Vörös 2021-03-08 07:18:55 +01:00
parent 663a7d2fe0
commit c501569dd7
3 changed files with 31 additions and 1 deletions

View file

@ -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
for dir in "numpy" "common"
for dir in "numpy" "common" "utils"
do
if ! env MICROPY_MICROPYTHON=micropython/ports/unix/micropython ./run-tests -d tests/"$dir"; then
for exp in *.exp; do

View 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))

View 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)