Repository navigation
Closed
Labels
bot-mislabeledIf you notice that the claude-bot mislabeled an issueIf you notice that the claude-bot mislabeled an issuebot-triagedThis is a label only to be used by the auto triage botThis is a label only to be used by the auto triage botenhancementNot as big of a feature, but technically not a bug. Should be easy to fixNot as big of a feature, but technically not a bug. Should be easy to fixmodule: deprecationmodule: numpyRelated to numpy support, and also numpy compatibility of our operatorsRelated to numpy support, and also numpy compatibility of our operatorstriagedThis issue has been looked at a team member, and triaged and prioritized into an appropriate moduleThis issue has been looked at a team member, and triaged and prioritized into an appropriate module
Description
🐛 Describe the bug
In NumPy 2, NumPy added a DeprecationWarning on __array_wrap__ to extend the information passed in and avoid an indefinite try/except chain.
This means that the e.g. the following gives a warning:
import warnings
import numpy as np
import torch
warnings.filterwarnings("error") # with this an error
np.delete(torch.arange(10), 0)
Now, the solution is straight forward: Just add the two new arguments and ignore them.
(torch has no scalars, and the context is info that was always there and you don't need). That is __array_wrap__(obj, context=None, return_scalar=None).
I'll guess end-users use this path but because of how DeprecationWarnings work they won't actually see them normally, so it makes sense it wasn't spotted.
It would be nice to escalate the warning to something visible, but I would prefer if by that time torch has the fix.
Versions
current main.
Metadata
Metadata
Assignees
Labels
bot-mislabeledIf you notice that the claude-bot mislabeled an issueIf you notice that the claude-bot mislabeled an issuebot-triagedThis is a label only to be used by the auto triage botThis is a label only to be used by the auto triage botenhancementNot as big of a feature, but technically not a bug. Should be easy to fixNot as big of a feature, but technically not a bug. Should be easy to fixmodule: deprecationmodule: numpyRelated to numpy support, and also numpy compatibility of our operatorsRelated to numpy support, and also numpy compatibility of our operatorstriagedThis issue has been looked at a team member, and triaged and prioritized into an appropriate moduleThis issue has been looked at a team member, and triaged and prioritized into an appropriate module
Activity
ogulcanaydogan commentedon Apr 28, 2026
I'd like to work on this. The fix is straightforward: update
__array_wrap__intorch/_tensor.pyto acceptcontext=None, return_scalar=Noneand ignore them, suppressing the NumPy 2 deprecation warning.Fix NumPy 2 DeprecationWarning in Tensor.__array_wrap__
Fix NumPy 2 DeprecationWarning in Tensor.__array_wrap__ (pytorch#187190)
Fix NumPy 2 DeprecationWarning in Tensor.__array_wrap__ (pytorch#187190)
Fix NumPy 2 DeprecationWarning in Tensor.__array_wrap__ (pytorch#187190)
Fix NumPy 2 DeprecationWarning in Tensor.__array_wrap__ (pytorch#187190…
Fix NumPy 2 DeprecationWarning in Tensor.__array_wrap__ (pytorch#187190…
Fix NumPy 2 DeprecationWarning in Tensor.__array_wrap__ (pytorch#187190…
Fix NumPy 2 DeprecationWarning in Tensor.__array_wrap__ (pytorch#187190…
Fix NumPy 2 DeprecationWarning in Tensor.__array_wrap__ (pytorch#187190…