10
0

Accepting request 1244373 from home:badshah400:branches:science

* Update to version 8.0.1.
* Re-enable all tests as they have been fixed upstream.
* Bump numpy requirement to allow numpy >= 2 in keeping with upstream.
* Update minimum versions in Requires and BuildRequires.
* Restore tests that now work: test_home_page, test_gudermannian, test_image.
* Drop python-Mathics-sympy1_13.patch: incorporated upstream.

OBS-URL: https://build.opensuse.org/request/show/1244373
OBS-URL: https://build.opensuse.org/package/show/science/python-Mathics?expand=0&rev=47
This commit is contained in:
2025-02-09 17:25:23 +00:00
committed by Git OBS Bridge
parent cc9519efd8
commit bded601aa7
5 changed files with 54 additions and 256 deletions

View File

@@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:d039a5dac244d7342abd29a5663d083ba28a86370f6b5cfddc6604ef42af150b
size 3062274

3
Mathics3-8.0.1.tar.gz Normal file
View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:4ce42e4bbb0aec61ab03ccd537f478dc2eabb953ab69073c07515a6e610c22fb
size 19546895

View File

@@ -1,224 +0,0 @@
From ef8a0ceeb213e5dd26a0dba8ec50b66c44c69c56 Mon Sep 17 00:00:00 2001
From: Juan Mauricio Matera <matera@fisica.unlp.edu.ar>
Date: Tue, 20 Aug 2024 09:18:51 -0300
Subject: [PATCH] fix tests for sympy conversions (#1073)
This PR just fixes the pytest, and marks some issues in the conversion
of Lambda functions.
---------
Co-authored-by: rocky <rb@dustyfeet.com>
---
mathics/core/symbols.py | 4 +-
test/core/test_sympy_python_convert.py | 71 +++++++++++++++++---------
2 files changed, 49 insertions(+), 26 deletions(-)
Index: Mathics3-7.0.0/mathics/core/symbols.py
===================================================================
--- Mathics3-7.0.0.orig/mathics/core/symbols.py
+++ Mathics3-7.0.0/mathics/core/symbols.py
@@ -14,8 +14,8 @@ from mathics.core.element import (
# I put this constants here instead of inside `mathics.core.convert.sympy`
# to avoid a circular reference. Maybe they should be in its own module.
-sympy_symbol_prefix = "_Mathics_User_"
-sympy_slot_prefix = "_Mathics_Slot_"
+sympy_symbol_prefix = "_mu_"
+sympy_slot_prefix = "_ms_"
# FIXME: This is repeated below
Index: Mathics3-7.0.0/test/core/test_sympy_python_convert.py
===================================================================
--- Mathics3-7.0.0.orig/test/core/test_sympy_python_convert.py
+++ Mathics3-7.0.0/test/core/test_sympy_python_convert.py
@@ -20,32 +20,39 @@ from mathics.core.convert.python import
from mathics.core.convert.sympy import from_sympy
from mathics.core.expression import Expression
from mathics.core.list import ListExpression
-from mathics.core.symbols import Symbol, SymbolPlus
+from mathics.core.symbols import (
+ Symbol,
+ SymbolPlus,
+ sympy_slot_prefix,
+ sympy_symbol_prefix,
+)
from mathics.core.systemsymbols import (
SymbolD,
SymbolDerivative,
+ SymbolFunction,
SymbolGamma,
SymbolIntegrate,
SymbolSin,
+ SymbolSlot,
)
class SympyConvert(unittest.TestCase):
def compare_to_sympy(self, mathics_expr, sympy_expr, **kwargs):
- mathics_expr.to_sympy(**kwargs) == sympy_expr
+ assert mathics_expr.to_sympy(**kwargs) == sympy_expr
def compare_to_mathics(self, mathics_expr, sympy_expr, **kwargs):
- mathics_expr == from_sympy(sympy_expr, **kwargs)
+ assert mathics_expr == from_sympy(sympy_expr, **kwargs)
def compare(self, mathics_expr, sympy_expr, **kwargs):
self.compare_to_sympy(mathics_expr, sympy_expr, **kwargs)
self.compare_to_mathics(mathics_expr, sympy_expr)
def testSymbol(self):
- self.compare(Symbol("Global`x"), sympy.Symbol("_Mathics_User_Global`x"))
+ self.compare(Symbol("Global`x"), sympy.Symbol(f"{sympy_symbol_prefix}Global`x"))
self.compare(
Symbol("_Mathics_User_x"),
- sympy.Symbol("_Mathics_User_System`_Mathics_User_x"),
+ sympy.Symbol(f"{sympy_symbol_prefix}System`_Mathics_User_x"),
)
def testReal(self):
@@ -81,15 +88,15 @@ class SympyConvert(unittest.TestCase):
def testAdd(self):
self.compare(
Expression(SymbolPlus, Integer1, Symbol("Global`x")),
- sympy.Add(sympy.Integer(1), sympy.Symbol("_Mathics_User_Global`x")),
+ sympy.Add(sympy.Integer(1), sympy.Symbol(f"{sympy_symbol_prefix}Global`x")),
)
def testIntegrate(self):
self.compare(
Expression(SymbolIntegrate, Symbol("Global`x"), Symbol("Global`y")),
sympy.Integral(
- sympy.Symbol("_Mathics_User_Global`x"),
- sympy.Symbol("_Mathics_User_Global`y"),
+ sympy.Symbol(f"{sympy_symbol_prefix}Global`x"),
+ sympy.Symbol(f"{sympy_symbol_prefix}Global`y"),
),
)
@@ -97,8 +104,8 @@ class SympyConvert(unittest.TestCase):
self.compare(
Expression(SymbolD, Symbol("Global`x"), Symbol("Global`y")),
sympy.Derivative(
- sympy.Symbol("_Mathics_User_Global`x"),
- sympy.Symbol("_Mathics_User_Global`y"),
+ sympy.Symbol(f"{sympy_symbol_prefix}Global`x"),
+ sympy.Symbol(f"{sympy_symbol_prefix}Global`y"),
),
)
@@ -111,11 +118,13 @@ class SympyConvert(unittest.TestCase):
)
expr = Expression(head, Symbol("Global`x"), Symbol("Global`y"))
- sfxy = sympy.Function(str("_Mathics_User_Global`f"))(
- sympy.Symbol("_Mathics_User_Global`x"),
- sympy.Symbol("_Mathics_User_Global`y"),
+ sfxy = sympy.Function(str(f"{sympy_symbol_prefix}Global`f"))(
+ sympy.Symbol(f"{sympy_symbol_prefix}Global`x"),
+ sympy.Symbol(f"{sympy_symbol_prefix}Global`y"),
+ )
+ sym_expr = sympy.Derivative(
+ sfxy, sympy.Symbol(f"{sympy_symbol_prefix}Global`x")
)
- sym_expr = sympy.Derivative(sfxy, sympy.Symbol("_Mathics_User_Global`x"))
self.compare_to_sympy(expr, sym_expr, **kwargs)
# compare_to_mathics fails because Derivative becomes D (which then evaluates to Derivative)
@@ -124,28 +133,28 @@ class SympyConvert(unittest.TestCase):
kwargs = {"converted_functions": set(["Global`f"])}
marg1 = Expression(Symbol("Global`f"), Symbol("Global`x"))
- sarg1 = sympy.Function(str("_Mathics_User_Global`f"))(
- sympy.Symbol("_Mathics_User_Global`x")
+ sarg1 = sympy.Function(str(f"{sympy_symbol_prefix}Global`f"))(
+ sympy.Symbol(f"{sympy_symbol_prefix}Global`x")
)
self.compare(marg1, sarg1, **kwargs)
marg2 = Expression(Symbol("Global`f"), Symbol("Global`x"), Symbol("Global`y"))
- sarg2 = sympy.Function(str("_Mathics_User_Global`f"))(
- sympy.Symbol("_Mathics_User_Global`x"),
- sympy.Symbol("_Mathics_User_Global`y"),
+ sarg2 = sympy.Function(str(f"{sympy_symbol_prefix}Global`f"))(
+ sympy.Symbol(f"{sympy_symbol_prefix}Global`x"),
+ sympy.Symbol(f"{sympy_symbol_prefix}Global`y"),
)
self.compare(marg2, sarg2, **kwargs)
self.compare(
Expression(SymbolD, marg2, Symbol("Global`x")),
- sympy.Derivative(sarg2, sympy.Symbol("_Mathics_User_Global`x")),
+ sympy.Derivative(sarg2, sympy.Symbol(f"{sympy_symbol_prefix}Global`x")),
**kwargs,
)
def testExpression(self):
self.compare(
Expression(SymbolSin, Symbol("Global`x")),
- sympy.sin(sympy.Symbol("_Mathics_User_Global`x")),
+ sympy.sin(sympy.Symbol(f"{sympy_symbol_prefix}Global`x")),
)
def testConstant(self):
@@ -155,14 +164,28 @@ class SympyConvert(unittest.TestCase):
def testGamma(self):
self.compare(
Expression(SymbolGamma, Symbol("Global`z")),
- sympy.gamma(sympy.Symbol("_Mathics_User_Global`z")),
+ sympy.gamma(sympy.Symbol(f"{sympy_symbol_prefix}Global`z")),
)
self.compare(
Expression(SymbolGamma, Symbol("Global`z"), Symbol("Global`x")),
sympy.uppergamma(
- sympy.Symbol("_Mathics_User_Global`z"),
- sympy.Symbol("_Mathics_User_Global`x"),
+ sympy.Symbol(f"{sympy_symbol_prefix}Global`z"),
+ sympy.Symbol(f"{sympy_symbol_prefix}Global`x"),
+ ),
+ )
+
+ def testSlots(self):
+ """check the conversion of slots in anonymous functions."""
+ sympy_symbol = sympy.Symbol("x")
+ sympy_lambda_expr = sympy.Lambda(sympy_symbol, sympy_symbol + 1)
+ # compare_to_sympy does not pass because Slot[1] are translated as
+ # functions
+ self.compare_to_mathics(
+ Expression(
+ SymbolFunction,
+ Expression(SymbolPlus, Integer1, Expression(SymbolSlot, Integer1)),
),
+ sympy_lambda_expr,
)
Index: Mathics3-7.0.0/mathics/builtin/testing_expressions/numerical_properties.py
===================================================================
--- Mathics3-7.0.0.orig/mathics/builtin/testing_expressions/numerical_properties.py
+++ Mathics3-7.0.0/mathics/builtin/testing_expressions/numerical_properties.py
@@ -42,8 +42,8 @@ class CoprimeQ(Builtin):
## CoprimeQ also works for complex numbers
## >> CoprimeQ[1+2I, 1-I]
## = True
-
- ## This test case is commenteted out because the result produced by sympy is wrong:
+
+ ## This test case is commented out because the result produced by sympy is wrong:
## In this case, both numbers can be factorized as 2 (2 + I) and 3 (2 + I):
## >> CoprimeQ[4+2I, 6+3I]
## = False
Index: Mathics3-7.0.0/pyproject.toml
===================================================================
--- Mathics3-7.0.0.orig/pyproject.toml
+++ Mathics3-7.0.0/pyproject.toml
@@ -23,7 +23,7 @@ dependencies = [
"python-dateutil",
"requests",
"setuptools",
- "sympy>=1.11,<1.13",
+ "sympy>=1.11,<1.14",
]
license = {text = "GPL"}
name = "Mathics3"

View File

@@ -1,3 +1,35 @@
-------------------------------------------------------------------
Sat Feb 8 15:46:46 UTC 2025 - Atri Bhattacharya <badshah400@gmail.com>
- Update to version 8.0.1:
* Some work was made on the Mathics3 Kernel to work in Python
3.13.
* The maximum version of numpy was increased to < 2.3 to allow
marimo to work.
* Correct for mismatch between ListExpression and tuple in
DispatchAtom.
* When the result of an evaluation is Symbol`Null, Mathics CLI
now does not show an Out[...]= line, following the behavior of
the WMA CLI.
* Aymptote rendering of platonic solids added.
* Document tagging code handles TeX math mode more completely,
Image tags in PDF properly.
* Updated documentation.
- Re-enable all tests as they have been fixed upstream.
- Bump numpy requirement to allow numpy >= 2 in keeping with
upstream.
-------------------------------------------------------------------
Wed Feb 5 09:09:22 UTC 2025 - Atri Bhattacharya <badshah400@gmail.com>
- Update to version 8.0.0:
* Too many changes to list, see
<https://github.com/Mathics3/mathics-core/releases/tag/8.0.0>.
- Update minimum versions in Requires and BuildRequires.
- Restore tests that now work: test_home_page, test_gudermannian,
test_image.
- Drop python-Mathics-sympy1_13.patch: incorporated upstream.
-------------------------------------------------------------------
Sun Feb 2 12:44:43 UTC 2025 - Atri Bhattacharya <badshah400@gmail.com>

View File

@@ -28,60 +28,59 @@
%define skip_python313 1
%define pyname Mathics3
%define src_ver 8.0.1
Name: python-Mathics%{psuffix}
Version: 7.0.0
Version: 8.0.1
Release: 0
Summary: A general-purpose computer algebra system
# Mathics itself is licensed as GPL-3.0 but it includes third-party software with MIT, BSD-3-Clause, and Apache-2.0 Licensing; also includes data from wikipedia licensed under CC-BY-SA-3.0 and GFDL-1.3
License: Apache-2.0 AND BSD-3-Clause AND GPL-3.0-only AND MIT
URL: https://mathics.github.io/
Source0: https://github.com/Mathics3/mathics-core/releases/download/%{version}/%{pyname}-%{version}.tar.gz
# PATCH-FIX-UPSTREAM python-Mathics-sympy1_13.patch badshah400@gmail.com -- Add compatibility for tests against sympy >= 1.13
Patch0: python-Mathics-sympy1_13.patch
BuildRequires: %{python_module Django >= 1.8}
BuildRequires: %{python_module Mathics-Scanner >= 1.4.1}
BuildRequires: %{python_module colorama}
BuildRequires: %{python_module devel}
BuildRequires: %{python_module mpmath >= 0.19}
BuildRequires: %{python_module numpy < 2}
BuildRequires: %{python_module numpy}
BuildRequires: %{python_module pexpect}
BuildRequires: %{python_module pip}
BuildRequires: %{python_module python-dateutil}
BuildRequires: %{python_module setuptools}
BuildRequires: %{python_module sympy >= 1.10.1}
BuildRequires: %{python_module sympy >= 1.13.0}
BuildRequires: %{python_module wheel}
BuildRequires: fdupes
BuildRequires: python-rpm-macros
Requires: python-Mathics-Scanner >= 1.3.0
Requires: python-Mathics-Scanner >= 1.4.1
Requires: python-Pint
Requires: python-llvmlite
Requires: python-Pympler
Requires: python-mpmath >= 0.19
Requires: python-numpy < 2
Requires: python-numpy
Requires: python-palettable
Requires: python-python-dateutil
Requires: python-requests
Requires: python-sympy >= 1.10.1
Requires: python-scipy
Requires: python-stopit
Requires: python-sympy >= 1.13.0
Requires: (python-Pillow >= 9.2 if python-base >= 3.7)
Requires(post): update-alternatives
Requires(postun): update-alternatives
Recommends: python-scikit-image >= 0.17
BuildArch: noarch
%if %{with test}
# SECTION For tests
BuildRequires: %{python_module Mathics = %{version}}
BuildRequires: %{python_module Mathics-Scanner >= 1.3.0}
BuildRequires: %{python_module Pillow >= 9.2 if %python-base >= 3.7}
BuildRequires: %{python_module Pint}
BuildRequires: %{python_module chardet}
BuildRequires: %{python_module llvmlite}
BuildRequires: %{python_module palettable}
BuildRequires: %{python_module pytest}
BuildRequires: %{python_module requests}
BuildRequires: %{python_module scikit-image >= 0.17}
BuildRequires: %{python_module stopit}
BuildRequires: %{python_module testsuite}
BuildRequires: %{python_module typing-extensions}
# /SECTION
%endif
Provides: python-Mathics3 = %{version}
BuildArch: noarch
%python_subpackages
%description
@@ -89,7 +88,7 @@ Mathics is a general-purpose computer algebra system (CAS). It is meant to be a
free, lightweight alternative to Mathematica.
%prep
%autosetup -p1 -n %{pyname}-%{version}
%autosetup -p1 -n mathics3-%{version}
# REMOVE SHEBANGS FROM FILES INSTALLED TO NON-EXEC LOCATIONS
pushd mathics
@@ -99,6 +98,9 @@ do
done
popd
# Unnecessary exec perms
chmod -x ./mathics/Packages/Rubi/Show{StepFormatting,StepRoutines}.m
%build
%if %{without test}
export USE_CYTHON=0
@@ -115,21 +117,9 @@ export USE_CYTHON=0
%if %{with test}
%check
PYTHONPATH+=:${PWD}
# test_gudermannian needs network access
# test_image: https://github.com/Mathics3/mathics-core/issues/837
DONTTEST='test_gudermannian or test_image'
# A whole swathe of tests no longer work: https://github.com/Mathics3/mathics-core/issues/1346
DONTTEST+=' or test_element or test_limit or test_private_doctests_'
DONTTEST+=' or test_associations_private_doctests or test_ArcCos or test_add'
DONTTEST+=' or test_set_and_clear or test_compare_many_members or test_cmp1_no_pass'
DONTTEST+=' or test_makeboxes_ or test_returncode or test_predicates_private_doctests'
if [ "%_lib" = "lib" ]; then
DONTTEST+=' or test_nintegrate or test_cli'
fi
export DONTTEST
export MATHICS_CHARACTER_ENCODING="ASCII"
export USE_CYTHON=0
%pytest -k "not (${DONTTEST})"
%pytest ./test
%endif
%if %{without test}