Skip to content

Decide how/if to have hooks for .imag/.real or general dtype specific attributes #13

Open

Description

@seberg

The .imag and .real properties of ndarray return views into the original array. This means they cannot be described, e.g. by UFuncs. We could add an imag/real method/slot to the new DTypes which:

  • Returns the offset into the existing dtype
  • Returns a new dtype
    With that information, the ndarray can return the new view.

We could allow dtypes to tag on more special attributes (think quaternions, etc.). But it seems dangerous, at least for now. However, another thing would be to do this through some special new attribute on ndarray, such as ndarray.elementwise.<method>(*args, **kwargs) calling special dtype.arr_methods.<method>(array, dtype, *args, *kwargs) or similar.

Activity

  1. mattip commented on Nov 21, 2019

    @mattip
    Collaborator

    Note that today np.ones(100, dtype='uint8').imag does actually create a zero-ed array

  2. added a commit that references this issue on Dec 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions