Skip to content

Commit

Permalink
Merge branch 'master' into doc-code-another-round-of-tiny-changes-1
Browse files Browse the repository at this point in the history
  • Loading branch information
mmatera authored Mar 14, 2024
2 parents 693ce4a + 27ec4d0 commit 86a53ec
Show file tree
Hide file tree
Showing 60 changed files with 1,972 additions and 1,342 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ jobs:
strategy:
matrix:
os: [windows]
python-version: ['3.10', '3.11']
# "make doctest" on MS Windows fails without showing much of a
# trace of where things went wrong on Python before 3.11.
python-version: ['3.11']
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
Expand All @@ -27,7 +29,7 @@ jobs:
# so we will be safe here. Another possibility would be check and install
# conditionally.
choco install --force llvm
choco install tesseract
# choco install tesseract
set LLVM_DIR="C:\Program Files\LLVM"
- name: Install Mathics3 with Python dependencies
run: |
Expand All @@ -46,8 +48,6 @@ jobs:
run: |
pip install pyocr # from full
pip install -e .[dev]
set PYTEST_WORKERS="-n3"
# Until we can't figure out what's up with TextRecognize:
make pytest gstest
make doctest o="--exclude TextRecognize"
make doctest
# make check
12 changes: 8 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ PYTHON ?= python3
PIP ?= pip3
BASH ?= bash
RM ?= rm
PYTEST_OPTIONS ?=

# Variable indicating Mathics3 Modules you have available on your system, in latex2doc option format
MATHICS3_MODULE_OPTION ?= --load-module pymathics.graph,pymathics.natlang
Expand Down Expand Up @@ -73,7 +74,7 @@ develop-full-cython: mathics/data/op-tables.json
$(PIP) install -e .[dev,full,cython]


#: Make distirbution: wheels, eggs, tarball
#: Make distribution: wheels, eggs, tarball
dist:
./admin-tools/make-dist.sh

Expand All @@ -84,13 +85,16 @@ install:
#: Run the most extensive set of tests
check: pytest gstest doctest

#: Run the most extensive set of tests
check-for-Windows: pytest-for-windows gstest doctest

#: Build and check manifest of Builtins
check-builtin-manifest:
$(PYTHON) admin-tools/build_and_check_manifest.py

#: Run pytest consistency and style checks
check-consistency-and-style:
MATHICS_LINT=t $(PYTHON) -m pytest test/consistency-and-style
MATHICS_LINT=t $(PYTHON) -m pytest $(PYTEST_OPTIONS) test/consistency-and-style

check-full: check-builtin-manifest check-builtin-manifest check

Expand All @@ -113,9 +117,9 @@ clean: clean-cython clean-cache
rm -f mathics/data/op-tables || true; \
rm -rf build || true

#: Run py.test tests. Use environment variable "o" for pytest options
#: Run pytest tests. Use environment variable "PYTEST_OPTIONS" for pytest options
pytest:
MATHICS_CHARACTER_ENCODING="ASCII" $(PYTHON) -m pytest $(PYTEST_WORKERS) test $o
MATHICS_CHARACTER_ENCODING="ASCII" $(PYTHON) -m pytest $(PYTEST_OPTIONS) $(PYTEST_WORKERS) test


#: Run a more extensive pattern-matching test
Expand Down
12 changes: 5 additions & 7 deletions mathics/builtin/assignments/assignment.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,14 +273,12 @@ class TagSet(Builtin, _SetOperator):
</dl>
Create an upvalue without using 'UpSet':
>> x /: f[x] = 2
= 2
>> f[x]
= 2
>> DownValues[f]
>> square /: area[square[s_]] := s^2
>> DownValues[square]
= {}
>> UpValues[x]
= {HoldPattern[f[x]] :> 2}
>> UpValues[square]
= {HoldPattern[area[square[s_]]] :> s ^ 2}
The symbol $f$ must appear as the ultimate head of $lhs$ or as the head of an element in $lhs$:
>> x /: f[g[x]] = 3;
Expand Down
2 changes: 1 addition & 1 deletion mathics/builtin/box/layout.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ class RowBox(BoxExpression):
summary_text = "horizontal arrange of boxes"

def __repr__(self):
return "RowBox[List[" + self.items.__repr__() + "]]"
return "RowBox[List[" + self.elements.__repr__() + "]]"

def eval_list(self, boxes, evaluation):
"""RowBox[boxes_List]"""
Expand Down
2 changes: 1 addition & 1 deletion mathics/builtin/colors/color_operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,7 @@ def result():
yield to_expression(
Symbol(out_palette_head),
*prototype,
elements_conversion_fn=MachineReal
elements_conversion_fn=MachineReal,
)

return to_mathics_list(*itertools.islice(result(), 0, at_most))
Expand Down
8 changes: 4 additions & 4 deletions mathics/builtin/drawing/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -654,7 +654,7 @@ def eval(
functions,
xexpr_limits,
yexpr_limits,
*options_to_rules(options)
*options_to_rules(options),
)

functions = self.get_functions_param(functions)
Expand Down Expand Up @@ -1501,7 +1501,7 @@ def final_graphics(self, graphics, options):
return Expression(
SymbolGraphics,
ListExpression(*graphics),
*options_to_rules(options, Graphics.options)
*options_to_rules(options, Graphics.options),
)


Expand Down Expand Up @@ -1936,7 +1936,7 @@ def auto_bins():
return Expression(
SymbolGraphics,
ListExpression(*graphics),
*options_to_rules(options, Graphics.options)
*options_to_rules(options, Graphics.options),
)


Expand Down Expand Up @@ -2622,5 +2622,5 @@ def final_graphics(self, graphics, options: dict):
return Expression(
SymbolGraphics3D,
ListExpression(*graphics),
*options_to_rules(options, Graphics3D.options)
*options_to_rules(options, Graphics3D.options),
)
47 changes: 7 additions & 40 deletions mathics/builtin/evaluation.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
# -*- coding: utf-8 -*-
"""Evaluation Control
Mathics3 takes an expression that it is given, and evaluates it. Built \
into the evaluation are primitives that allow finer control over the \
process of evaluation in cases where it is needed.
"""

from mathics.core.atoms import Integer
from mathics.core.attributes import A_HOLD_ALL, A_HOLD_ALL_COMPLETE, A_PROTECTED
from mathics.core.builtin import Builtin, Predefined
from mathics.core.evaluation import (
MAX_RECURSION_DEPTH,
Evaluation,
set_python_recursion_limit,
)
from mathics.core.evaluation import MAX_RECURSION_DEPTH, set_python_recursion_limit


class RecursionLimit(Predefined):
Expand Down Expand Up @@ -303,38 +305,3 @@ class Sequence(Builtin):
summary_text = (
"a sequence of arguments that will automatically be spliced into any function"
)


class Quit(Builtin):
"""
<url>:WMA link:https://reference.wolfram.com/language/ref/Quit.html</url>
<dl>
<dt>'Quit'[]
<dd> Terminates the Mathics session.
<dt>'Quit[$n$]'
<dd> Terminates the mathics session with exit code $n$.
</dl>
<dl>
<dt>'Exit'[]
<dd> Terminates the Mathics session.
<dt>'Exit[$n$]'
<dd> Terminates the mathics session with exit code $n$.
</dl>
"""

rules = {
"Exit[n___]": "Quit[n]",
}
summary_text = "terminate the session"

def eval(self, evaluation: Evaluation, n):
"%(name)s[n___]"
exitcode = 0
if isinstance(n, Integer):
exitcode = n.get_int_value()
raise SystemExit(exitcode)
2 changes: 1 addition & 1 deletion mathics/builtin/fileformats/htmlformat.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def xml_object(tree):
return Expression(
Expression(SymbolXMLObject, String("Document")),
to_mathics_list(*declaration),
*node_to_xml_element(tree.getroot())
*node_to_xml_element(tree.getroot()),
)


Expand Down
2 changes: 1 addition & 1 deletion mathics/builtin/fileformats/xmlformat.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ def xml_object(root):
return Expression(
to_expression("XMLObject", String("Document")),
to_mathics_list(*declaration),
*node_to_xml_element(root)
*node_to_xml_element(root),
)


Expand Down
Loading

0 comments on commit 86a53ec

Please sign in to comment.