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

float32 has priority over float64 for scalar integer ufunc inputs with other arrays #5895

Open
pv opened this issue May 20, 2015 · 0 comments

Comments

@pv
Copy link
Member

pv commented May 20, 2015

Consider this:

>>> from scipy.special import sph_harm
>>> sph_harm.types
['llff->F', 'lldd->D', 'ffff->F', 'dddd->D']
>>> sph_harm(0,[0],0,0).dtype
dtype('complex64')   # <- uh-oh
>>> sph_harm(0,[0],0,0.0).dtype
dtype('complex128')
>>> sph_harm(0,0,0,0).dtype
dtype('complex128')
>>> sph_harm(0,[0],[0],0).dtype
dtype('complex128')

Apparently, the ufunc loop selector prefers to cast integers to float32 in this case, which is somewhat surprising. This may have to do with the fact that given an integer array as one of the first two arguments, there are still two possible loop choices, and deciding which to use would need considering appropriate scalar casting rules for the last two arguments. Note that if one of the last arguments is an array instead of a scalar, the dtype decision is as expected, so maybe this is an issue with scalar special cases.

@pv pv changed the title float32 has priority over float64 for integer ufunc inputs float32 has priority over float64 for scalar integer ufunc inputs with other arrays May 20, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant