You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Well, by reading the numpy.full docs I infer that the fill value should be a scalar, a number,
while here we see a use of tuple as the 2nd fill argument.
I agree with @anntzer that the behaviour here is quite random.
Should we print an error for every non-scalar fill value? Or just trace special cases like the one above and handle them individually?
Edit: Is it possible to change the fill value definition to support any data type?
Seems like an obvious bug. Was there a reason why we are not using res.fill() in np.full0/np.full_like? It feels like there may have been, but also that it should solve this issue.
Or indeed just do res[...] = fill_value, which, like @anntzer, I would have expected to happen (and in a completely separate thread, I noted that this equally fast - cannot find it anymore though!)
Fair point. I suppose the only difference is that fill and indexing will coerce to array with the new dtype, while copyto coerces to an array first.
The other question would be if we should change the copyto behaviour then...
EDIT: OK, fill is a bit a different possibly, since it goes to a specific scalar assignment path, but I wouldn't be surprised that in the end it just means the same thing.
One would expect that
np.full(shape, fill, dtype)
works ast = np.empty(shape, dtype); t[:] = fill; return t
but...Reproducing code example:
the following works
but the following doesn't
As a side effect, even if it was decided that the above was not supported, the following certainly gives a wrong result:
Numpy/Python version information:
The text was updated successfully, but these errors were encountered: