Skip to content

Inconsistent behaviour of numpy.real and numpy.imag functions #8386

@momchilj

Description

@momchilj

The numpy.real and numpy.imag functions show what is IMHO inconsistent behaviour compared to other numpy functions - when they are given a a single value as parameter (as opposed to array) they return an array instead of a single value. Compare this to the behaviour of numpy.angle, numpy.conj, numpy.sin, etc. functions which return a scalar when given a scalar. Example code:

np.version
'1.11.1'
a = 1.0 + 1j
np.real(a)
array(1.0)
np.imag(a)
array(1.0)
np.angle(a)
0.78539816339744828
np.conj(a)
(1-1j)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions