Skip to content
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

BUG: incorrect promotion of scalars in logspace #24957

Closed
seberg opened this issue Oct 19, 2023 · 4 comments · Fixed by #25919
Closed

BUG: incorrect promotion of scalars in logspace #24957

seberg opened this issue Oct 19, 2023 · 4 comments · Fixed by #25919

Comments

@seberg
Copy link
Member

seberg commented Oct 19, 2023

gh-23275 added broadcasting before the promotion happened, which is incorrect for 0-D objects as they may have special promotion rules (value-based or Python int/float/complex being special).

First reported at cupy/cupy#7946

Ping @byrdie since it was your PR.

@seberg seberg added this to the 1.26.2 release milestone Oct 19, 2023
@byrdie
Copy link
Contributor

byrdie commented Oct 19, 2023

@seberg, thanks for the ping, do you know what the best fix might be? Seems like we need to avoid a call to np.array() right?

@seberg
Copy link
Member Author

seberg commented Oct 19, 2023

At the moment the issue is the broadcasting and not the asarray(). In the future, we could just broadcast bins (and thus convert to array) if it isn't a python int/float/complex (not sure complex makes sense at all).
That is, right now 0-D objects/arrays are "special", in the future Python int/float/complex would be (but not our 0-D objects).

We should probably turn around the logic simply. Convert base to an array (doesn't hurt much anyway), but only ever call the broadcasting step when base is not 0-D.

There is another little thing that Marten might complain about anyway, that this uses asarray() and that loses subclass info (although these days that is probably less relevant due to __array_function__). asanyarray() would be better.

(May need another bit of thought, but hopefully it helps and if you think about it also and reach similar conclusions we are good).

@charris charris modified the milestones: 1.26.4 release, 2.0.0 release Feb 5, 2024
seberg added a commit to seberg/numpy that referenced this issue Feb 11, 2024
Closes numpygh-24957, although the handling of `dtype=` being passed
in looks wrong, but that is a different issue.
seberg added a commit to seberg/numpy that referenced this issue Feb 11, 2024
Closes numpygh-24957, although the handling of `dtype=` being passed
in looks wrong, but that is a different issue.
seberg added a commit to seberg/numpy that referenced this issue Feb 11, 2024
Closes numpygh-24957, although the handling of `dtype=` being passed
in looks wrong, but that is a different issue.
seberg added a commit to seberg/numpy that referenced this issue Feb 11, 2024
Closes numpygh-24957, although the handling of `dtype=` being passed
in looks wrong, but that is a different issue.
@rgommers
Copy link
Member

rgommers commented Mar 3, 2024

Leaving the 2.0.0 milestone for now since it's type promotion related, but this doesn't seem blocking.

@mhvk
Copy link
Contributor

mhvk commented Mar 3, 2024

Fix in #25919.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants