Closed
Description
Describe the bug
micropython-ulab/code/ndarray.c
Lines 1625 to 1629 in 88ef893
ivalue > -128
should be ivalue >= -128
Similar here:
micropython-ulab/code/ndarray.c
Lines 1617 to 1622 in 88ef893
ivalue < -32767
should be ivalue < -32768
ulab
version: 6.7.4-4D-c
To Reproduce
from ulab import numpy as np
foo = np.ones((1), dtype=np.int8) * -128
print("should be int8:", foo)
foo = np.ones((1), dtype=np.int8) * -32768
print("should be int16:", foo)
Expected behavior
Should print:
should be int8: array([-128], dtype=int8)
should be int16: array([-32768.0], dtype=int16)
Instead prints:
should be int8: array([-128], dtype=int16)
should be int16: array([-32768.0], dtype=float32)
It incorrectly promotes the dtype
to int16
and float
respectively.
Additional context
Testing on my end, making the suggested changes fixes the problem.