Skip to content

Commit

Permalink
fix bug
Browse files Browse the repository at this point in the history
  • Loading branch information
chaoming0625 committed Aug 10, 2024
1 parent 3075498 commit 26f38ea
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions brainunit/math/_fun_accept_unitless.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def _fun_accept_unitless_unary(
return func(x, *args, **kwargs)
else:
assert isinstance(unit_to_scale, Unit), f'unit_to_scale should be a Unit instance. Got {unit_to_scale}'
return func(x.to_decimal_num(unit_to_scale), *args, **kwargs)
return func(x.to_decimal(unit_to_scale), *args, **kwargs)
else:
assert unit_to_scale is None, f'Unit should be None for the function "{func}" when "x" is not a Quantity.'
return func(x, *args, **kwargs)
Expand Down Expand Up @@ -763,7 +763,7 @@ def _fun_accept_unitless_return_keep_unit(
return func(x, *args, **kwargs)
else:
assert isinstance(unit_to_scale, Unit), f'unit_to_scale should be a Unit instance. Got {unit_to_scale}'
r = func(x.to_decimal_num(unit_to_scale), *args, **kwargs)
r = func(x.to_decimal(unit_to_scale), *args, **kwargs)
return jax.tree.map(lambda a: a * unit_to_scale, r)
else:
# assert unit_to_scale is None, f'Unit should be None for the function "{func}" when "x" is not a Quantity.'
Expand Down Expand Up @@ -993,15 +993,15 @@ def _fun_accept_unitless_binary(
x = x.mantissa
else:
assert isinstance(unit_to_scale, Unit), f'unit_to_scale should be a Unit instance. Got {unit_to_scale}'
x = x.to_decimal_num(unit_to_scale)
x = x.to_decimal(unit_to_scale)
if isinstance(y, Quantity):
if unit_to_scale is None:
assert y.is_unitless, (f'Input should be unitless for the function "{func}" '
f'when scaling "unit_to_scale" is not provided.')
y = y.mantissa
else:
assert isinstance(unit_to_scale, Unit), f'unit_to_scale should be a Unit instance. Got {unit_to_scale}'
y = y.to_decimal_num(unit_to_scale)
y = y.to_decimal(unit_to_scale)
return func(x, y, *args, **kwargs)


Expand Down

0 comments on commit 26f38ea

Please sign in to comment.