Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RealAbs and RealSign #885

Merged
merged 4 commits into from
Jul 21, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The link name should be what Wikipedia calls it, so this should be "Sign function". Wikipedia mentions that this is also called "Signum"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I can change this in another iteration.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have included that change in #886, which is the next round of patches.

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
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
Loading