Closed HugoNumworks closed 1 year ago
Whenever there is a user-facing change, increment the version number in https://github.com/v923z/micropython-ulab/blob/47ad73ab57ded2bea7685b9ef7ba23c275a6d788/code/ulab.c#L36. This would be 6.0.8 now.
I'm trying to understand what this PR wants to solve: you call the function https://github.com/v923z/micropython-ulab/blob/47ad73ab57ded2bea7685b9ef7ba23c275a6d788/code/ndarray.c#L217 which basically tells you, whether an object is iterable. If so, then you iterate over it in https://github.com/v923z/micropython-ulab/blob/45d637550c5486ba619e8ceb34e946058c0d8b36/code/numpy/poly.c#L238-L247 Why is a conversion to a list going to help?
I'm trying to understand what this PR wants to solve: you call the function
I just needed Polyval to handle scalar and not only lists. Otherwise,
np.polyval([3,0,1], 5)
raises a inputs are not iterable
message.
Converting to a list beforehand was an easy way to handle np.polyval([3,0,1], 5)
as if the user inputted np.polyval([3,0,1], [5])
The big flaw is that it returns a list in both case which is not Numpy's behavior, so I have to rework this anyway.
You could call the https://github.com/v923z/micropython-ulab/blob/47ad73ab57ded2bea7685b9ef7ba23c275a6d788/code/ndarray.c#L1690 function in that case.
@v923z , thanks for the suggestion. I went with a different implementation where I no longer need to convert to a list. Now a scalar is returned if the second argument is a scalar. I also incremented the version number and factorized a method. I Hope this helps !
This would allow the evaluation of a polynomial at single value, as allowed in numpy. https://numpy.org/doc/stable/reference/generated/numpy.polyval.html