refactor(MO): Separate value and tree in MOs
This commit is contained in:
@@ -183,22 +183,22 @@ def mofraction_mofraction(left, right):
|
||||
num = Tree("+", left.numerator, right.numerator)
|
||||
return Tree("/", num, left.denominator)
|
||||
|
||||
denom_lcm = lcm(left.denominator, right.denominator)
|
||||
denom_lcm = lcm(left.denominator.value, right.denominator.value)
|
||||
|
||||
if left.denominator == denom_lcm:
|
||||
if left.denominator.value == denom_lcm:
|
||||
left_frac = left
|
||||
else:
|
||||
multiply_by = denom_lcm // left.denominator
|
||||
left_num = Tree("*", left.numerator, MO.factory(multiply_by))
|
||||
left_denom = Tree("*", left.denominator, MO.factory(multiply_by))
|
||||
multiply_by = MO.factory(denom_lcm // left.denominator.value)
|
||||
left_num = Tree("*", left.numerator, multiply_by)
|
||||
left_denom = Tree("*", left.denominator, multiply_by)
|
||||
left_frac = Tree("/", left_num, left_denom)
|
||||
|
||||
if right.denominator == denom_lcm:
|
||||
if right.denominator.value == denom_lcm:
|
||||
right_frac = right
|
||||
else:
|
||||
multiply_by = denom_lcm // right.denominator
|
||||
right_num = Tree("*", right.numerator, MO.factory(multiply_by))
|
||||
right_denom = Tree("*", right.denominator, MO.factory(multiply_by))
|
||||
multiply_by = MO.factory(denom_lcm // right.denominator.value)
|
||||
right_num = Tree("*", right.numerator, multiply_by)
|
||||
right_denom = Tree("*", right.denominator, multiply_by)
|
||||
right_frac = Tree("/", right_num, right_denom)
|
||||
|
||||
return Tree("+", left_frac, right_frac)
|
||||
|
||||
Reference in New Issue
Block a user