numpy
numpy copied to clipboard
BUG: Fixed Bug #25744 - Raise error for put method on empty array
I've addressed the issue (See #25744) with checks to verify array size is greater than zero when performing put operation and if not, to raise a ValueError with appropriate error message.
I've made the following improvements:
Ensure program does not stay in a loop forever when empty array supplied to put method. Changes done in the built-in C file ensures the program works for both:
import numpy as np
array = np.asarray(list())
np.put(array, 1, 1, mode="wrap")
and
import numpy as np
array = np.asarray(list())
array.put(array, 1, 1, mode="wrap")
Thanks. Please note that, first, this PR is not reviewable due to automatic code reformatting. And second, that until/unless gh-25760 is stalled for a week or two, I don't think we will focus on this one.