-
-
Notifications
You must be signed in to change notification settings - Fork 12.1k
Open
Labels
Description
Describe the issue:
In Numpy versions 2.4.2, command np.common_type(ar1.dtype, ar2.dtype) raises AttributeError for single precision floating point arrays, while np.common_type(ar1, ar2) works as expected.
Reproduce the code example:
import numpy as np
dt_c = np.common_type(np.dtype('f4'), np.dtype('f4')) # raises AttributeErrorError message:
Python 3.14.3 | packaged by conda-forge | (main, Feb 9 2026, 21:56:02) [GCC 14.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy as np
>>> np.common_type(np.dtype('f4'), np.dtype('f4'))
Traceback (most recent call last):
File "<python-input-1>", line 1, in <module>
np.common_type(np.dtype('f4'), np.dtype('f4'))
~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/opavlyk/miniforge/envs/np_new/lib/python3.14/site-packages/numpy/lib/_type_check_impl.py", line 697, in common_type
t = a.dtype.type
^^^^^^^
AttributeError: 'numpy.dtypes.Float32DType' object has no attribute 'dtype'. Did you mean: 'type'?
>>> np.__version__Python and NumPy Versions:
Reproduced with NumPy 2.4.2 and Python 3.12 and Python 3.14
Runtime Environment:
Ubuntu 24.04
How does this issue affect you or how did you find it:
Ran into exception in my code, worked around by feeding arrays into common_type rather than their data types.
Reactions are currently unavailable