Skip to content

DEP: Deprecate find_common_type which is broken e.g. for datetimes #21703

@rabernat

Description

@rabernat

Describe the issue:

When I call np.find_common_type with multiple identical datetime64 types, I would expect to get the same type back, since all the inputs are identical. Instead, I always get dtype('O').

Reproduce the code example:

import numpy as np
dt = np.dtype('datetime64[ns]')
dt1 = np.find_common_type([dt], []) 
# this works; both dtype('<M8')
assert dt1 == dt
dt2 = np.find_common_type([dt, dt], [])
# this fails; dt2 is dtype('O')
assert dt2 == dt

Error message:

No response

NumPy/Python version information:

1.21.2 3.9.9 | packaged by conda-forge | (main, Dec 20 2021, 02:41:37)
[Clang 11.1.0 ]

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions