Skip to content

Commit cb0f619

Browse files
committed
Merge remote-tracking branch 'upstream/master' into informationfix
2 parents f837718 + e38eb25 commit cb0f619

10 files changed

Lines changed: 17 additions & 7288 deletions

File tree

mathics/builtin/arithmetic.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212
import sympy
1313
import mpmath
14-
import math
1514

1615
from mathics.builtin.base import (
1716
Builtin,
@@ -1350,7 +1349,7 @@ def apply(self, expr, evaluation):
13501349
# try expanding the expression
13511350
exprexp = Expression("ExpandAll", expr).evaluate(evaluation)
13521351
exprexp = exprexp.to_sympy()
1353-
result = _iszero(exprexp)
1352+
result = _iszero(exprexp)
13541353
if result is None:
13551354
# Can't get exact answer, so try approximate equal
13561355
numeric_val = Expression("N", expr).evaluate(evaluation)

mathics/builtin/base.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
#!/usr/bin/env python3
22
# -*- coding: utf-8 -*-
33

4-
import mpmath
54
import re
65
import sympy
76

87
from functools import total_ordering
98
import importlib
109
from itertools import chain
11-
1210
import typing
1311
from typing import Any, cast
1412

@@ -531,7 +529,7 @@ def apply(self, expr, evaluation) -> Symbol:
531529

532530

533531
class SympyFunction(SympyObject):
534-
def get_constant(self, precision, have_mpmath=False):
532+
def get_constant(self, precision, evaluation, have_mpmath=False):
535533
try:
536534
d = get_precision(precision, evaluation)
537535
except PrecisionValueError:

mathics/builtin/calculus.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ class Integrate(SympyFunction):
369369
370370
Integration in TeX:
371371
>> Integrate[f[x], {x, a, b}] // TeXForm
372-
= \int_a^bf\left[x\right] \, dx
372+
= \int_a^b f\left[x\right] \, dx
373373
374374
#> DownValues[Integrate]
375375
= {}
@@ -437,12 +437,12 @@ class Integrate(SympyFunction):
437437
'Integrate[list_List, x_]': 'Integrate[#, x]& /@ list',
438438

439439
'MakeBoxes[Integrate[f_, x_], form:StandardForm|TraditionalForm]':
440-
r'''RowBox[{"\[Integral]", MakeBoxes[f, form], "\[InvisibleTimes]",
440+
r'''RowBox[{"\[Integral]","\[InvisibleTimes]", MakeBoxes[f, form], "\[InvisibleTimes]",
441441
RowBox[{"\[DifferentialD]", MakeBoxes[x, form]}]}]''',
442442
'MakeBoxes[Integrate[f_, {x_, a_, b_}], '
443443
'form:StandardForm|TraditionalForm]':
444444
r'''RowBox[{SubsuperscriptBox["\[Integral]", MakeBoxes[a, form],
445-
MakeBoxes[b, form]], MakeBoxes[f, form], "\[InvisibleTimes]",
445+
MakeBoxes[b, form]], "\[InvisibleTimes]" , MakeBoxes[f, form], "\[InvisibleTimes]",
446446
RowBox[{"\[DifferentialD]", MakeBoxes[x, form]}]}]''',
447447
}
448448

mathics/builtin/datentime.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ class TimeConstrained(Builtin):
149149
150150
Possible issues: for certain time-consuming functions (like simplify)
151151
which are based on sympy or other libraries, it is possible that
152-
the evaluation continues after the timeout. However, at the end of the evaluation, the function will return $\$Aborted$ and the results will not affect
152+
the evaluation continues after the timeout. However, at the end of the evaluation, the function will return $\\$Aborted$ and the results will not affect
153153
the state of the mathics kernel.
154154
155155
"""

mathics/core/definitions.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,12 @@ def load_pymathics_module(self, module, remove_on_quit=True):
157157
for name, item in newsymbols.items():
158158
if name != "System`MakeBoxes":
159159
item.contribute(self, is_pymodule=True)
160+
161+
162+
onload = loaded_module.pymathics_version_data.get("onload", None)
163+
if onload:
164+
onload(self)
165+
160166
return loaded_module
161167

162168
def clear_pymathics_modules(self):

mathics/core/expression.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,9 @@
22
# cython: language_level=3
33
# -*- coding: utf-8 -*-
44

5-
import ast
65
import sympy
76
import mpmath
87
import math
9-
import inspect
108
import re
119

1210
import typing
@@ -141,7 +139,7 @@ def from_python(arg):
141139

142140
class KeyComparable(object):
143141
def get_sort_key(self):
144-
raise NotImplemented
142+
raise NotImplementedError
145143

146144
def __lt__(self, other) -> bool:
147145
return self.get_sort_key() < other.get_sort_key()
@@ -381,7 +379,7 @@ def do_format(self, evaluation, form):
381379
leaves = self.get_leaves()
382380
include_form = False
383381
# If the expression is enclosed by a Format
384-
# takes the form from the expression and
382+
# takes the form from the expression and
385383
# removes the format from the expression.
386384
if head in formats and len(leaves) == 1:
387385
expr = leaves[0]
@@ -432,7 +430,7 @@ def format_expr(expr):
432430
if result is not None and result != expr:
433431
return result.evaluate(evaluation)
434432
return None
435-
433+
436434
formatted = format_expr(expr)
437435
if formatted is not None:
438436
result = formatted.do_format(evaluation, form)
@@ -2137,7 +2135,7 @@ def __neg__(self) -> 'Rational':
21372135

21382136
@property
21392137
def is_zero(self) -> bool:
2140-
return self.numerator().is_zero and not self.denominator().is_zero()
2138+
return self.numerator().is_zero # (implicit) and not (self.denominator().is_zero)
21412139

21422140

21432141
class Real(Number):

0 commit comments

Comments
 (0)