Skip to content

Commit

Permalink
Merge pull request #20 from quantumlib/toplevel
Browse files Browse the repository at this point in the history
Fix type deduction bug
  • Loading branch information
NoureldinYosri authored Nov 13, 2024
2 parents d6de826 + d407943 commit 4e186b3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
9 changes: 9 additions & 0 deletions test/test_dimension.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,12 @@ def test_arithmetic_ops_preserve_type_array(

c = a / 11
assert all(c == u * [2 / 11, 3 / 11])


def test_division_type() -> None:
t: tunits.Time = 3 * tunits.ns

t = t / 2
assert t == 1.5 * tunits.ns

assert isinstance(1 / t, tunits.Value)
2 changes: 0 additions & 2 deletions tunits/core/cython/with_unit.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -274,8 +274,6 @@ cdef class WithUnit:
conversion_div(left.conv, right.conv),
left.base_units / right.base_units,
left.display_units / right.display_units, Value, ValueArray)
if left._is_dimensionless():
return right.__with_value(left.value / right.value)
if right._is_dimensionless():
return left.__with_value(left.value / right.value)
return raw_WithUnit(left.value / right.value,
Expand Down

0 comments on commit 4e186b3

Please sign in to comment.