-
Notifications
You must be signed in to change notification settings - Fork 2k
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
numpy: Overloads between scalars and arrays can produce confusing results #1392
Comments
EricCousineau-TRI
added a commit
to EricCousineau-TRI/pybind11
that referenced
this issue
May 11, 2018
…s can produce confusing results
EricCousineau-TRI
added a commit
to EricCousineau-TRI/pybind11
that referenced
this issue
May 11, 2018
Added something like the above workaround to the current PR: 5e75f0b EDIT: Note that this can also be workaround by having required |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Relates numpy/numpy#10404 - can transplant the main info here if need be
Given how NumPy permits converting arrays of size 1 to scalars (regardless of dimension), this can create confusing interplay between overloads of an array and a scalar numeric value, especially if the array type is meant to be implicitly convertible from
int
orfloat
.Reproduction code:
As a workaround, a user could define some wrapper type, like
scalar_only<T>
, and an accompanyingtype_converter<scalar_only<T>>
, which explicitly rejects any containers that are iterable.Regarding how to solve this, I unfortunately do not have any good ideas (though it would be nice if/when numpy/numpy#10615 lands).
The text was updated successfully, but these errors were encountered: