Skip to content

np.around and np.round supports complex numbers, but not np.trunc #17100

@xuhdev

Description

@xuhdev

Both around and round supports complex input, but not trunc. This looks a bit abnormal.

Reproducing code example:

In [1]: import numpy as np

In [2]: a=np.array([complex(1+1j)]*3)

In [3]: np.around(a)
Out[3]: array([1.+1.j, 1.+1.j, 1.+1.j])

In [4]: np.round(a)
Out[4]: array([1.+1.j, 1.+1.j, 1.+1.j])

In [5]: np.trunc(a)
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-5-17494546b8df> in <module>
----> 1 np.trunc(a)

TypeError: ufunc 'trunc' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''

Numpy/Python version information:

1.19.1 3.7.3 (default, Jul 25 2020, 13:03:44) 
[GCC 8.3.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