[Numpy-discussion] Passing output array to bincount

2022-10-21 Thread ntessore
Hello, I would like to propose adding the `out` array as an optional parameter to `bincount`. This makes `bincount` very useful when iteratively tallying data with large indices. Consider this example tallying batches of values from some fictional source of data: >>> tally = np.zeros(1**

[Numpy-discussion] Re: Passing output array to bincount

2022-10-21 Thread Sebastian Berg
On Thu, 2022-10-20 at 23:26 +, ntess...@pm.me wrote: > Hello, > Hi, I don't have a strong opinion yet it does seem potentially useful, but I think there would be some details to hash out in the proposal. Some thoughts: * `np.add.at` should be able to do what you want (but of course is very

[Numpy-discussion] Re: Passing output array to bincount

2022-10-21 Thread Nicolas Tessore
Hi, thanks for your reply. Let me try and answer your points one by one. > * `np.add.at` should be able to do what you want (but of course is very > slow right now, and maybe hard to get as fast as bincount even if > improved). It is indeed far too slow to be useful for my particular applicat

[Numpy-discussion] Re: NEP 50 and cast safety for scalar assignment/conversions

2022-10-21 Thread Aaron Meurer
I'm probably not understanding all the subtleties here. In the documentation for can_cast (and other places), it says, "'safe' means only casts which can preserve values are allowed." So by that definition, I think 'safe' casting should disallow 5000 to be cast to int8, because it would not preserv