X Tutup
Skip to content

BUG: common_type(dtype('f4'), dtype('f4')) raises AttributeError unexpectedly #30890

@oleksandr-pavlyk

Description

@oleksandr-pavlyk

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 AttributeError

Error 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      X Tutup