Skip to content

Commit

Permalink
Prevent NumPy from creating object arrays of Quantities on (ndarray *…
Browse files Browse the repository at this point in the history
… Quantity) multiplication by setting __array_ufunc__=None.
  • Loading branch information
mjziebarth committed Sep 22, 2024
1 parent bc6768c commit 75bf451
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -175,12 +175,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### [Unreleased]
#### Added
- Support for `dtype` and `copy` parameters in `Quantity._array`.
- Added typing stubs for `Unit` and `Quantity`.

#### Changed
- Remove use of deprecated `numpy.array` with `copy=False`.
- Removed internal inconsistency in how scalar and array-valued Quantities
were handled in the `Quantity.wrapper()` routine. Now, scalar-valued
quantities can similarly be filled from the C++ side.
- Prevent NumPy from creating an object array on left-hand multiplication
by setting `__array_ufunc__ = None`.


### [0.4.0] - 2024-08-12
Expand Down
2 changes: 2 additions & 0 deletions cyantities/quantity.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,8 @@ cdef class Quantity:
"""
__dict__: dict

__array_ufunc__ = None

def __init__(self, value, unit, bool copy=True):
#
# First determine the values (scalar / ndarray)
Expand Down

0 comments on commit 75bf451

Please sign in to comment.