Skip to content

Quantity with units returns True for __eq__ with plain numpy array  #146

Open

Description

@bjodah

Consider this:

In [10]: 2.1*pq.m == np.array(2.1)
Out[10]: True

I would have expected it to return True only if the Quantity instance was dimensionless.
What do others think?

EDIT:
since the numbers (arrays) cannot be added to each other, I think it really should be an error:

>>> 3*pq.m + 3
ValueError ...

Activity

  1. added 2 commits that reference this issue on Jan 28, 2018
    ec1ca74
    dcaecba
  2. apdavison commented on Jan 29, 2018

    @apdavison
    Contributor

    Similarly,

    In [4]: [2.1, 2.2]*pq.m == np.array([2.1, 2.2])
    Out[4]: array([ True,  True], dtype=bool)

    I think this behaviour should be changed, but it would be a major change, potentially affecting a lot of downstream libraries, so an extended period with deprecation warnings would be needed.

    Please can other people chime in with their opinion?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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