Skip to content

Commit

Permalink
Merge branch 'RealAbs_and_RealSign' into arithmetic_refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
mmatera committed Jul 21, 2023
2 parents b3119c5 + 4d8f5b1 commit c32daa2
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 19 deletions.
26 changes: 21 additions & 5 deletions mathics/builtin/arithmetic.py
Original file line number Diff line number Diff line change
Expand Up @@ -829,7 +829,9 @@ def evaluate(self, evaluation: Evaluation):

class Im(SympyFunction):
"""
<url>:WMA link:https://reference.wolfram.com/language/ref/Im.html</url>
<url>
:WMA link:
https://reference.wolfram.com/language/ref/Im.html</url>
<dl>
<dt>'Im[$z$]'
Expand Down Expand Up @@ -1215,7 +1217,12 @@ class Real_(Builtin):

class RealAbs(Builtin):
"""
<url>:WMA link:https://reference.wolfram.com/language/ref/RealAbs.html</url>
<url>
:Abs (Real):
https://en.wikipedia.org/wiki/Absolute_value</url> (<url>
:WMA link:
https://reference.wolfram.com/language/ref/RealAbs.html
</url>)
<dl>
<dt>'RealAbs[$x$]'
Expand Down Expand Up @@ -1283,8 +1290,12 @@ def test(self, expr) -> bool:

class RealSign(Builtin):
"""
<url>:WMA link:https://reference.wolfram.com/language/ref/RealAbs.html</url>
<url>
:Signum:
https://en.wikipedia.org/wiki/Sign_function</url> (<url>
:WMA link:
https://reference.wolfram.com/language/ref/RealSign.html
</url>)
<dl>
<dt>'RealSign[$x$]'
<dd>returns $-1$, $0$ or $1$ depending on whether $x$ is negative,
Expand Down Expand Up @@ -1319,7 +1330,12 @@ def eval(self, x: Number, evaluation: Evaluation) -> Optional[Integer]:

class Sign(SympyFunction):
"""
<url>:WMA link:https://reference.wolfram.com/language/ref/Sign.html</url>
<url>
:Sign:
https://en.wikipedia.org/wiki/Sign_function</url> (<url>
:WMA link:
https://reference.wolfram.com/language/ref/Sign.html
</url>)
<dl>
<dt>'Sign[$x$]'
Expand Down
1 change: 0 additions & 1 deletion mathics/builtin/testing_expressions/equality_inequality.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ def numerify_args(items, evaluation) -> list:
n_items = []
for item in items:
if not isinstance(item, Number):
# TODO: use $MaxExtraPrecision insterad of hard-coded 50
item = eval_N(item, evaluation, SymbolMaxExtraPrecision)
n_items.append(item)
items = n_items
Expand Down
10 changes: 8 additions & 2 deletions mathics/doc/latex/doc2latex.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import mathics
from mathics import __version__, settings, version_string
from mathics.core.definitions import Definitions
from mathics.core.load_builtin import import_and_load_builtins
from mathics.doc.latex_doc import LaTeXMathicsDocumentation
from mathics.eval.pymathics import PyMathicsLoadException, eval_LoadModule

Expand Down Expand Up @@ -172,15 +173,17 @@ def main():
dest="chapters",
metavar="CHAPTER",
help="only test CHAPTER(s). "
"You can list multiple chapters by adding a comma (and no space) in between chapter names.",
"You can list multiple chapters by adding a comma (and no space) in between "
"chapter names.",
)
parser.add_argument(
"--sections",
"-s",
dest="sections",
metavar="SECTION",
help="only test SECTION(s). "
"You can list multiple chapters by adding a comma (and no space) in between chapter names.",
"You can list multiple chapters by adding a comma (and no space) in between "
"chapter names.",
)
parser.add_argument(
"--load-module",
Expand Down Expand Up @@ -210,6 +213,9 @@ def main():

# LoadModule Mathics3 modules to pull in modules, and
# their docstrings

import_and_load_builtins()

if args.pymathics:
definitions = Definitions(add_builtin=True)
for module_name in args.pymathics.split(","):
Expand Down
7 changes: 0 additions & 7 deletions mathics/eval/testing_expressions.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,6 @@
from mathics.core.expression import Expression
from mathics.core.systemsymbols import SymbolDirectedInfinity

# TODO: Remove me. The following function is not used anywhere
"""
def cmp(a, b) -> int:
"Returns 0 if a == b, -1 if a < b and 1 if a > b"
return (a > b) - (a < b)
"""


def do_cmp(x1, x2) -> Optional[int]:

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
INSTALL_REQUIRES += [
"numpy<=1.24",
"llvmlite",
"sympy>=1.8, < 1.12",
"sympy>=1.8",
# Pillow 9.1.0 supports BigTIFF with big-endian byte order.
# ExampleData image hedy.tif is in this format.
# Pillow 9.2 handles sunflowers.jpg
Expand Down
6 changes: 3 additions & 3 deletions test/builtin/calculus/test_solve.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ def test_solve():
# the test to fail.
(None, None, None),
(
"Solve[{(7+x)*ma == 167, (5+x)*mb == 167, (7+5)*(ma+mb) == 334}, {ma, mb, x}]",
"Solve[{(7+x)*ma == 167, (5+x)*mb == 167, (7+5)*(ma+mb) == 334}, {ma, mb, x}]//Sort",
"{{ma -> 1169 / 12 - 167 Sqrt[37] / 12, mb -> -835 / 12 + 167 Sqrt[37] / 12, x -> Sqrt[37]}, {ma -> 1169 / 12 + 167 Sqrt[37] / 12, mb -> -835 / 12 - 167 Sqrt[37] / 12, x -> -Sqrt[37]}}",
"Issue63",
),
(
"Solve[{(7+x)*ma == 167, (5+x)*mb == 167, (7+5)*(ma+mb) == 334}, {x, ma, mb}]",
"{{x -> -Sqrt[37], ma -> 1169 / 12 + 167 Sqrt[37] / 12, mb -> -835 / 12 - 167 Sqrt[37] / 12}, {x -> Sqrt[37], ma -> 1169 / 12 - 167 Sqrt[37] / 12, mb -> -835 / 12 + 167 Sqrt[37] / 12}}",
"Solve[{(7+x)*ma == 167, (5+x)*mb == 167, (7+5)*(ma+mb) == 334}, {x, ma, mb}]//Sort",
"{{x -> Sqrt[37], ma -> 1169 / 12 - 167 Sqrt[37] / 12, mb -> -835 / 12 + 167 Sqrt[37] / 12},{x -> -Sqrt[37], ma -> 1169 / 12 + 167 Sqrt[37] / 12, mb -> -835 / 12 - 167 Sqrt[37] / 12}}",
"Issue 208",
),
(
Expand Down

0 comments on commit c32daa2

Please sign in to comment.