Skip to content

Commit e315265

Browse files
committed
merge
2 parents a6524b4 + 90d9c7d commit e315265

26 files changed

Lines changed: 345 additions & 7590 deletions

CHANGES.rst

Lines changed: 205 additions & 203 deletions
Large diffs are not rendered by default.

MANIFEST.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ include Makefile
77
include mathics/Makefile
88
include mathics/Makefile
99
recursive-include mathics *.py
10-
recursive-include test *.py
10+
recursive-include test *.py *.m

Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ build:
3737
develop:
3838
$(PIP) install -e .
3939

40+
#: Make distirbution: wheels, eggs, tarball
41+
dist:
42+
./admin-tools/make-dist.sh
43+
4044
#: Install mathics
4145
install:
4246
$(PYTHON) setup.py install

README.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ Mathics is released under the GNU General Public License Version 3 (GPL3).
4646
.. |Travis| image:: https://secure.travis-ci.org/mathics/Mathics.svg?branch=master
4747
.. _Travis: https://travis-ci.org/mathics/Mathics
4848
.. _PyPI: https://pypi.org/project/Mathics/
49-
.. |mathicsscript| image:: https://mathics.org/screenshots/mathicsscript.png
50-
.. |mathicssserver| image:: https://mathics.org/screenshots/mathicsserver.png
49+
.. |mathicsscript| image:: https://github.com/Mathics3/mathicsscript/blob/master/screenshots/mathicsscript1.gif
50+
.. |mathicssserver| image:: https://mathics.org/images/mathicsserver.png
5151
.. |Latest Version| image:: https://badge.fury.io/py/Mathics3.svg
5252
:target: https://badge.fury.io/py/Mathics3
5353
.. |Pypi Installs| image:: https://pepy.tech/badge/Mathics3

admin-tools/make-dist.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#!/bin/bash
12
PACKAGE=mathics3
23

34
# FIXME put some of the below in a common routine
@@ -15,7 +16,7 @@ fi
1516

1617

1718
cd ..
18-
source $PACKAGE/version.py
19+
source mathics/version.py
1920
echo $__version__
2021

2122
for pyversion in $PYVERSIONS; do

mathics/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
version_string += f", cython {version_info['cython']}"
5050

5151
license_string = """\
52-
Copyright (C) 2011-2020 The Mathics Team.
52+
Copyright (C) 2011-2021 The Mathics Team.
5353
This program comes with ABSOLUTELY NO WARRANTY.
5454
This is free software, and you are welcome to redistribute it
5555
under certain conditions.

mathics/builtin/arithmetic.py

Lines changed: 0 additions & 1 deletion
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,

mathics/builtin/assignment.py

Lines changed: 33 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import mathics.builtin
66
from mathics.builtin.base import (
77
Builtin, BinaryOperator, PostfixOperator, PrefixOperator)
8-
from mathics.core.expression import (Expression, Symbol, SymbolFailed, valid_context_name,
8+
from mathics.core.expression import (Expression, Symbol, SymbolFailed, SymbolNull, valid_context_name,
99
system_symbols, String)
1010
from mathics.core.rules import Rule, BuiltinRule
1111
from mathics.builtin.patterns import RuleDelayed
@@ -833,23 +833,34 @@ def _get_usage_string(symbol, evaluation, htmlout=False):
833833
definition = evaluation.definitions.get_definition(symbol.name)
834834
ruleusage = definition.get_values_list('messages')
835835
usagetext = None
836-
from mathics.builtin import builtins
837836
import re
838-
bio = builtins.get(definition.name)
839-
837+
# First look at user definitions:
838+
for rulemsg in ruleusage:
839+
if rulemsg.pattern.expr.leaves[1].__str__() == "\"usage\"":
840+
usagetext = rulemsg.replace.value
841+
if usagetext is not None:
842+
# Maybe, if htmltout is True, we should convert
843+
# the value to a HTML form...
844+
return usagetext
845+
# Otherwise, look at the pymathics, and builtin docstrings:
846+
builtins = evaluation.definitions.builtin
847+
pymathics = evaluation.definitions.pymathics
848+
bio = pymathics.get(definition.name)
849+
if bio is None:
850+
bio = builtins.get(definition.name)
851+
840852
if bio is not None:
841853
from mathics.doc.doc import Doc
854+
docstr = bio.builtin.__class__.__doc__
855+
if docstr is None:
856+
return None
842857
if htmlout:
843-
usagetext = Doc(bio.__class__.__doc__).text(0)
858+
usagetext = Doc(docstr).html()
844859
else:
845-
usagetext = Doc(bio.__class__.__doc__).text(0)
860+
usagetext = Doc(docstr).text(0)
846861
usagetext = re.sub(r'\$([0-9a-zA-Z]*)\$', r'\1', usagetext)
847-
# For built-in symbols, looks for a docstring.
848-
# Looks for the "usage" message. For built-in symbols, if there is an "usage" chain, overwrite the __doc__ information.
849-
for rulemsg in ruleusage:
850-
if rulemsg.pattern.expr.leaves[1].__str__() == "\"usage\"":
851-
usagetext = rulemsg.replace.value
852-
return usagetext
862+
return usagetext
863+
return None
853864

854865

855866
class Information(PrefixOperator):
@@ -919,7 +930,7 @@ class Information(PrefixOperator):
919930

920931
def format_definition(self, symbol, evaluation, options, grid=True):
921932
'StandardForm,TraditionalForm,OutputForm: Information[symbol_, OptionsPattern[Information]]'
922-
ret = Symbol('Null')
933+
ret = SymbolNull
923934
lines = []
924935
if isinstance(symbol, String):
925936
evaluation.print_out(symbol)
@@ -1014,7 +1025,7 @@ def rhs(expr):
10141025
def format_definition_input(self, symbol, evaluation, options):
10151026
'InputForm: Information[symbol_, OptionsPattern[Information]]'
10161027
self.format_definition(symbol, evaluation, options, grid=False)
1017-
ret = Symbol("Null")
1028+
ret = SymbolNull
10181029
return ret
10191030

10201031

@@ -1757,17 +1768,19 @@ def apply(self, module, evaluation):
17571768
except ImportError as e:
17581769
evaluation.message(self.get_name(), 'notfound', module)
17591770
return SymbolFailed
1760-
1771+
except PyMathicsLoadException as e:
1772+
evaluation.message(self.get_name(), 'notmathicslib', module)
1773+
return SymbolFailed
1774+
else:
17611775
# Add Pymathics` to $ContextPath so that when user don't
17621776
# have to qualify Pymathics variables and functions,
17631777
# as the those in the module just loaded.
17641778
# Following the example of $ContextPath in the WL
17651779
# reference manual where PackletManager appears first in
17661780
# the list, it seems to be preferable to add this PyMathics
17671781
# at the beginning.
1768-
context_path = evaluation.definitions.get_context_path()
1769-
if "Pymathics`" not in context_path:
1770-
context_path.insert(0, "Pymathics`")
1771-
evaluation.definitions.set_context_path(context_path)
1772-
1782+
context_path = evaluation.definitions.get_context_path()
1783+
if "Pymathics`" not in context_path:
1784+
context_path.insert(0, "Pymathics`")
1785+
evaluation.definitions.set_context_path(context_path)
17731786
return module

mathics/builtin/base.py

Lines changed: 2 additions & 4 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

@@ -270,6 +268,7 @@ def contextify_form_name(f):
270268
attributes=attributes,
271269
options=options,
272270
defaultvalues=defaults,
271+
builtin=self
273272
)
274273
if is_pymodule:
275274
definitions.pymathics[name] = definition
@@ -532,7 +531,7 @@ def apply(self, expr, evaluation) -> Symbol:
532531

533532

534533
class SympyFunction(SympyObject):
535-
def get_constant(self, precision, have_mpmath=False):
534+
def get_constant(self, precision, evaluation, have_mpmath=False):
536535
try:
537536
d = get_precision(precision, evaluation)
538537
except PrecisionValueError:
@@ -855,4 +854,3 @@ def from_expression(expr):
855854
return CountableInteger(0, upper_limit=True)
856855

857856
return None # leave original expression unevaluated
858-

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

0 commit comments

Comments
 (0)