Skip to content

Commit

Permalink
Track Mathics API changes
Browse files Browse the repository at this point in the history
  • Loading branch information
rocky committed Jul 17, 2023
1 parent f6b2ed1 commit 6d44cf3
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 25 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:

jobs:
build:
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
strategy:
matrix:
python-version: ['3.9', '3.10']
Expand Down
8 changes: 4 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
from setuptools import find_namespace_packages, setup

# Ensure user has the correct Python version
if sys.version_info < (3, 6):
print("Mathics support Python 3.6 and above; you have %d.%d" % sys.version_info[:2])
if sys.version_info < (3, 7):
print("Mathics support Python 3.7 and above; you have %d.%d" % sys.version_info[:2])
sys.exit(-1)


Expand Down Expand Up @@ -53,7 +53,7 @@ def read(*rnames):
version=__version__,
packages=find_namespace_packages(include=["pymathics.*"]),
install_requires=[
"Mathics3 >=6.0.0,<7.1.0",
"Mathics3 >=6.1.0,<7.1.0",
"click>=8.0",
"joblib>=1.0.1",
"langid", # replace with a supported newer package, e.g. via spacy
Expand All @@ -76,11 +76,11 @@ def read(*rnames):
"Intended Audience :: Science/Research",
"License :: OSI Approved :: GNU General Public License v3 (GPLv3)",
"Programming Language :: Python",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
"Topic :: Scientific/Engineering",
Expand Down
46 changes: 26 additions & 20 deletions test/helper.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
import time
from typing import Optional

from mathics.core.load_builtin import import_and_load_builtins
from mathics.session import MathicsSession

session = MathicsSession(add_builtin=True, catch_interrupt=False)
import_and_load_builtins()

# Set up a Mathics3 session with definitions.
# For consistency set the character encoding ASCII which is
# the lowest common denominator available on all systems.
session = MathicsSession(character_encoding="ASCII")
session = MathicsSession(
character_encoding="ASCII", add_builtin=True, catch_interrupt=False
)


def reset_session(add_builtin=True, catch_interrupt=False):
Expand Down Expand Up @@ -38,28 +41,31 @@ def check_evaluation(
Helper function to test Mathics expression against
its results
Compares the expressions represented by ``str_expr`` and ``str_expected`` by evaluating
the first, and optionally, the second.
Compares the expressions represented by ``str_expr`` and ``str_expected`` by
evaluating the first, and optionally, the second.
to_string_expr: If ``True`` (default value) the result of the evaluation is converted
into a Python string. Otherwise, the expression is kept as an Expression
object. If this argument is set to ``None``, the session is reset.
to_string_expr: If ``True`` (default value) the result of the evaluation is
converted into a Python string. Otherwise, the expression is kept
as an Expression object. If this argument is set to ``None``, the
session is reset.
failure_message (str): message shown in case of failure
hold_expected (bool): If ``False`` (default value) the ``str_expected`` is evaluated. Otherwise,
the expression is considered literally.
hold_expected (bool): If ``False`` (default value) the ``str_expected`` is
evaluated. Otherwise, the expression is considered literally.
to_string_expected: If ``True`` (default value) the expected expression is
evaluated and then converted to a Python string. result of the evaluation is converted
into a Python string. If ``False``, the expected expression is kept as an Expression object.
to_python_expected: If ``True``, and ``to_string_expected`` is ``False``, the result of evaluating ``str_expr``
is compared against the result of the evaluation of ``str_expected``, converted into a
Python object.
expected_messages ``Optional[tuple[str]]``: If a tuple of strings are passed into this parameter, messages and prints raised during
the evaluation of ``str_expr`` are compared with the elements of the list. If ``None``, this comparison
is ommited.
evaluated and then converted to a Python string. result of the
evaluation is converted into a Python string. If ``False``,
the expected expression is kept as an Expression object.
to_python_expected: If ``True``, and ``to_string_expected`` is ``False``, the
result of evaluating ``str_expr`` is compared against the result of
the evaluation of ``str_expected``, converted into a Python object.
expected_messages ``Optional[tuple[str]]``: If a tuple of strings are passed into
this parameter, messages and prints raised during the evaluation of
``str_expr`` are compared with the elements of the list. If
``None``, this comparison is ommited.
"""
if str_expr is None:
reset_session()
Expand Down Expand Up @@ -105,7 +111,7 @@ def check_evaluation(
assert (
expected_len == got_len
), f"expected {expected_len}; got {got_len}. Messages: {outs}"
for (out, msg) in zip(outs, msgs):
for out, msg in zip(outs, msgs):
if out != msg:
print(f"out:<<{out}>>")
print(" and ")
Expand Down

0 comments on commit 6d44cf3

Please sign in to comment.