Skip to content

.real doesn't work on object arrays (Trac #1142) #1740

Description

@thouis

Original ticket http://projects.scipy.org/numpy/ticket/1142 on 2009-06-19 by @inducer, assigned to unknown.

numpy could really do a better job here by propagating the .real to the elements of the object array:

Python 2.5.4 (r254:67916, Feb 18 2009, 03:00:47) 
[GCC 4.3.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy as n
>>> n.__version__
'1.3.0'
>>> a = n.array(5+7j)
>>> b = n.array([a], dtype=object)
>>> b.real
array([(5+7j)], dtype=object)
>>> n.real(b)
array([(5+7j)], dtype=object)

Summary by @seberg:

Object arrays could call .real on all objects, but that would not return a view as typically promised by arr.real. It seems that moving forward here may require a new function that returns a copy?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions