Skip to content

Commit

Permalink
Merge pull request #889 from Mathics3/partial-arithmetic-refactor
Browse files Browse the repository at this point in the history
Start to reduce/refactor arithmetic ...
  • Loading branch information
rocky committed Jul 25, 2023
2 parents 9b3575d + 7a1241c commit fbef666
Show file tree
Hide file tree
Showing 18 changed files with 716 additions and 681 deletions.
18 changes: 12 additions & 6 deletions mathics/builtin/arithfns/basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,19 @@
"""
Basic Arithmetic
The functions here are the basic arithmetic operations that you might find on a calculator.
The functions here are the basic arithmetic operations that you might find \
on a calculator.
"""

from mathics.builtin.arithmetic import _MPMathFunction, create_infix
from mathics.builtin.base import BinaryOperator, Builtin, PrefixOperator, SympyFunction
from mathics.builtin.arithmetic import create_infix
from mathics.builtin.base import (
BinaryOperator,
Builtin,
MPMathFunction,
PrefixOperator,
SympyFunction,
)
from mathics.core.atoms import (
Complex,
Integer,
Expand Down Expand Up @@ -387,7 +394,7 @@ def eval(self, items, evaluation):
return eval_Plus(*items_tuple)


class Power(BinaryOperator, _MPMathFunction):
class Power(BinaryOperator, MPMathFunction):
"""
<url>
:Exponentiation:
Expand Down Expand Up @@ -531,7 +538,7 @@ class Power(BinaryOperator, _MPMathFunction):
def eval_check(self, x, y, evaluation):
"Power[x_, y_]"

# Power uses _MPMathFunction but does some error checking first
# Power uses MPMathFunction but does some error checking first
if isinstance(x, Number) and x.is_zero:
if isinstance(y, Number):
y_err = y
Expand Down Expand Up @@ -788,7 +795,6 @@ def inverse(item):
and isinstance(item.elements[1], (Integer, Rational, Real))
and item.elements[1].to_sympy() < 0
): # nopep8

negative.append(inverse(item))
elif isinstance(item, Rational):
numerator = item.numerator()
Expand Down
Loading

0 comments on commit fbef666

Please sign in to comment.