Skip to content

Commit

Permalink
Fix test bug on deepcopy
Browse files Browse the repository at this point in the history
  • Loading branch information
Routhleck committed Jul 14, 2024
1 parent 9324d6a commit ad88471
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion brainunit/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1629,6 +1629,7 @@ def _binary_operation(
else:
new_unit = Unit(1, dim=new_dim, register=False)
result = value_operation(self.value, other.value)

r = Quantity(result, dim=new_dim, unit=Unit(1, dim=new_unit.dim, name=new_unit.name, dispname=new_unit.dispname))

if inplace:
Expand Down Expand Up @@ -1891,6 +1892,9 @@ def __reduce__(self):
ptp = wrap_function_keep_dimensions(jnp.ptp)
ravel = wrap_function_keep_dimensions(jnp.ravel)

def __deepcopy__(self, memodict={}):
return Quantity(self.value, dim=self.dim, unit=self.unit)

def round(
self,
decimals: int = 0,
Expand Down Expand Up @@ -1969,7 +1973,7 @@ def conjugate(self) -> 'Quantity':

def copy(self) -> 'Quantity':
"""Return a copy of the quantity."""
return type(self)(jnp.copy(self.value), dim=self.dim)
return type(self)(jnp.copy(self.value), dim=self.dim, unit=self.unit)

def dot(self, b) -> 'Quantity':
"""Dot product of two arrays."""
Expand Down

0 comments on commit ad88471

Please sign in to comment.