v923z / micropython-ulab

a numpy-like fast vector module for micropython, circuitpython, and their derivatives
https://micropython-ulab.readthedocs.io/en/latest
MIT License
408 stars 113 forks source link

Numpy compatibility for the type of single ndarray members #400

Open arnonsen opened 3 years ago

arnonsen commented 3 years ago

On formal Numpy, the output for print(type((np.array([1],dtype=np.int32)[0]))) is <class 'numpy.int32'>, the array items keeps their types when used as scalars. On ulab the items out of the array becomes 'int' or 'float'. Is it worthwhile supporting this feature on Ulab, is there any added value for this feature ?

v923z commented 3 years ago

@arnonsen

On ulab the items out of the array becomes 'int' or 'float'. Is it worthwhile supporting this feature on Ulab, is there any added value for this feature ?

I don't think so: the micropython objects are integers or floats, there is no distinction between uint8, and int16. I believe, the only case, where the type of the integer matters is, when you pair it with an ndarray. But I have just sorted that out.