Skip to content

Commit 7a1241c

Browse files
committed
Start to reduce/refactor arithmetic ...
Remove stuff from mathics.builtin.arithmetic that does not belong there: * _MPMathFunction -> MPMathFunction and move to mathics.buitin.base * _MPMathMultiFunction -> MPMathFunction and move to mathics.builtin.base * Abs, Piecewise, RealAbs, RealSign, Sign moved to numeric to follow WMA organization better The corresponding eval routines will be gone over in another PR. This one is already large. Url's gone over to make this not exceed standard line limit. Note that the formatting has been gone over to follow the existing pattern that we have been using. cythonization in mathics.builtin class files removed. It is not clear this has benefit in modern Pythons, especially in this kind of builtin function and all of this needs to be retested if not rethought.
1 parent 9b3575d commit 7a1241c

File tree

18 files changed

+716
-681
lines changed

18 files changed

+716
-681
lines changed

mathics/builtin/arithfns/basic.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,19 @@
22
"""
33
Basic Arithmetic
44
5-
The functions here are the basic arithmetic operations that you might find on a calculator.
5+
The functions here are the basic arithmetic operations that you might find \
6+
on a calculator.
67
78
"""
89

9-
from mathics.builtin.arithmetic import _MPMathFunction, create_infix
10-
from mathics.builtin.base import BinaryOperator, Builtin, PrefixOperator, SympyFunction
10+
from mathics.builtin.arithmetic import create_infix
11+
from mathics.builtin.base import (
12+
BinaryOperator,
13+
Builtin,
14+
MPMathFunction,
15+
PrefixOperator,
16+
SympyFunction,
17+
)
1118
from mathics.core.atoms import (
1219
Complex,
1320
Integer,
@@ -387,7 +394,7 @@ def eval(self, items, evaluation):
387394
return eval_Plus(*items_tuple)
388395

389396

390-
class Power(BinaryOperator, _MPMathFunction):
397+
class Power(BinaryOperator, MPMathFunction):
391398
"""
392399
<url>
393400
:Exponentiation:
@@ -531,7 +538,7 @@ class Power(BinaryOperator, _MPMathFunction):
531538
def eval_check(self, x, y, evaluation):
532539
"Power[x_, y_]"
533540

534-
# Power uses _MPMathFunction but does some error checking first
541+
# Power uses MPMathFunction but does some error checking first
535542
if isinstance(x, Number) and x.is_zero:
536543
if isinstance(y, Number):
537544
y_err = y
@@ -788,7 +795,6 @@ def inverse(item):
788795
and isinstance(item.elements[1], (Integer, Rational, Real))
789796
and item.elements[1].to_sympy() < 0
790797
): # nopep8
791-
792798
negative.append(inverse(item))
793799
elif isinstance(item, Rational):
794800
numerator = item.numerator()

0 commit comments

Comments
 (0)