Skip to content

In-Place Operations (+=, -=, /=, *=) Yield Incorrect Units #254

@Moritz-Alexander-Kern

Description

@Moritz-Alexander-Kern

While migrating Elephant to numpy >= 2.0 we discovered the following bug, where in place basic operations +=, -=, /= and *= result in incorrect units.

Minimal example to reproduce:

a = 5 * pq.s
b = 6 * pq.kg

a /= b  # results incorrectly in a = 0.833 * s

a = a/b  # results in a = 0.833 * s/kg (expected)

With:

  • Python 3.13.1
  • quantities 0.16.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    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