-
-
Notifications
You must be signed in to change notification settings - Fork 10.9k
ufunc identity of -inf #7702
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Fyi the function already exists as np.logaddexp |
I guess the question then becomes whether |
@njsmith Wow, thanks, I had thought I checked well enough... ;) |
@mhvk I don't necessarily agree: someone could be indexing a plain array to filter instead of using a ma, or someone could be initializing a result for a generic reduce where some of the loops are plain-old for loops (not over an array that actually exists) so you don't have to build the whole thing in memory. (The latter was my application.) It's a little more work to specialcase the first value even if I require it to exist. It does look like it might be more trouble / complication-adding than it's worth to add the ability to have an identity of -inf, but I think there is some utility to it. |
Adding -inf from within numpy is reasonably easy, we recently added the -1, so you could find a template on how to do it. I would not mind if we had a way of defining the identity more specific, though. One could also think about an |
If we want to allow arbitrary identity values, I think we should pull out There was another recent PR about identity at #8255 |
There didn't seem to be any value to a `assign_identity` function - all we actually care about is the value to assign. This also fixes numpy#8860 as a side-effect, and paves the way for: * easily adding more values (numpy#7702) * using the identity in more places (numpy#834)
Many thanks, @eric-wieser |
I'm afraid this is a way off from being merged since it would break the ufunc abi, so I'd prefer to leave this open. |
Oops, I misread (I thought it was merged). Thanks all the same :) |
There didn't seem to be any value to a `assign_identity` function - all we actually care about is the value to assign. This also fixes numpy#8860 as a side-effect, and paves the way for: * easily adding more values (numpy#7702) * using the identity in more places (numpy#834)
I would like to write a function that, given
log(x)
andlog(y)
, will computelog(x + y)
. The identity for this islog(0) = -inf
. Currently, numpy only allows the values of 0, 1, -1, andNone
, as far as I can tell. It would be nice for my purposes if -inf or an arbitrary value could be used.The text was updated successfully, but these errors were encountered: