Thanks to visit codestin.com
Credit goes to github.com

Skip to content

BUG: np.ceil/np.floor fails when specified dtype is int #26988

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

Closed
mcrumiller opened this issue Jul 19, 2024 · 2 comments
Closed

BUG: np.ceil/np.floor fails when specified dtype is int #26988

mcrumiller opened this issue Jul 19, 2024 · 2 comments
Labels

Comments

@mcrumiller
Copy link

mcrumiller commented Jul 19, 2024

Describe the issue:

When using np.ceil or np.floor, you cannot specify an integer return dtype.

Reproduce the code example:

import numpy as np

np.floor(3/5, dtype=np.int32)  # fails
np.ceil(3/5, dtype=np.int32)  # fails

np.floor(3/5, dtype=np.float32)  # succeeds

Error message:

TypeError: No loop matching the specified signature and casting was found for ufunc floor

Python and NumPy Versions:

python 3.11.7
numpy 2.0.0

@seberg
Copy link
Member

seberg commented Jul 20, 2024

In practice identical to gh-26766. dtype= doesn't (just) specify the result, it specifies the calculation loop. And there is no integer loop (i.e. it doesn't never causes casting of the output).

@seberg
Copy link
Member

seberg commented Jul 23, 2024

Closing, the PR is merged, so the particular thing should work now.

@seberg seberg closed this as completed Jul 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants