Skip to content

Commit

Permalink
make __array__ safe for numpy < 2
Browse files Browse the repository at this point in the history
  • Loading branch information
NoureldinYosri committed Nov 11, 2024
1 parent ae2e05c commit 36284db
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion tunits/core/cython/with_unit_value_array.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,9 @@ class ValueArray(WithUnit):

def __array__(WithUnit self, dtype=None, copy: bool=False):
if self.is_dimensionless:
# TODO: pass copy to np.asarray.
return np.asarray(conversion_to_double(self.conv) * self.value,
dtype=dtype, copy=copy)
dtype=dtype)

unit_array = np.full_like(self.value, self.unit, dtype=object)
result = self.value * unit_array
Expand Down

0 comments on commit 36284db

Please sign in to comment.