Skip to content

Remove Maxima pexpect interface #40265

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/doc/en/constructions/plotting.rst
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ Terminal application.)
::

sage: maxima.eval('load("plotdf");')
'".../share/maxima.../share/dynamics/plotdf.lisp"'
.../share/maxima.../share/dynamics/plotdf.lisp...
sage: maxima.eval('plotdf(x+y,[trajectory_at,2,-0.1]); ') # not tested

This plots a direction field (the plotdf Maxima package was also
Expand Down
8 changes: 0 additions & 8 deletions src/doc/en/developer/coding_basics.rst
Original file line number Diff line number Diff line change
Expand Up @@ -186,14 +186,6 @@ included in one of the following places:
:func:`importlib.resources.as_file`. It should be imported in the
same way as shown above.

- Older code in the Sage library accesses
the package data in more direct ways. For example,
:sage_root:`src/sage/interfaces/maxima.py` uses the file
:sage_root:`src/sage/interfaces/maxima.lisp` at runtime, so it
refers to it as::

os.path.join(os.path.dirname(__file__), 'sage-maxima.lisp')

- In an appropriate subdirectory of :sage_root:`src/sage/ext_data/`.
(At runtime, it is then available in the directory indicated by
``SAGE_EXTCODE``). For example, if ``file`` is placed in
Expand Down
2 changes: 0 additions & 2 deletions src/doc/en/reference/calculus/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ Internal functionality supporting calculus
- :doc:`sage/symbolic/expression_conversions`
- :doc:`sage/symbolic/benchmark`
- :doc:`sage/symbolic/random_tests`
- :doc:`sage/symbolic/maxima_wrapper`
- :doc:`External integrators <sage/symbolic/integration/external>`
- :doc:`External interpolators <sage/calculus/interpolators>`

Expand Down Expand Up @@ -94,7 +93,6 @@ Internal functionality supporting calculus
sage/calculus/interpolators
sage/calculus/functions
sage/calculus/var
sage/symbolic/maxima_wrapper
sage/symbolic/operators
sage/symbolic/benchmark
sage/symbolic/random_tests
Expand Down
1 change: 0 additions & 1 deletion src/doc/en/reference/interfaces/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ and testing to make sure nothing funny is going on).
sage/interfaces/mathematica
sage/interfaces/mathics
sage/interfaces/matlab
sage/interfaces/maxima
sage/interfaces/maxima_abstract
sage/interfaces/maxima_lib
sage/interfaces/mupad
Expand Down
41 changes: 26 additions & 15 deletions src/sage/calculus/calculus.py
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,10 @@
Note that ``x`` is still ``x``, since the
maxima used by the calculus package is different than the one in
the interactive interpreter.
Clear the maxima variables to avoid interference with other tests::

sage: maxima('kill(x,y)')
done

Check to see that the problem with the variables method mentioned
in :issue:`3779` is actually fixed::
Expand Down Expand Up @@ -395,7 +399,7 @@
Check if maxima has redundant variables defined after initialization,
see :issue:`9538`::

sage: maxima = sage.interfaces.maxima.maxima
sage: maxima = sage.interfaces.maxima_lib.maxima
sage: maxima('f1')
f1
sage: sage.calculus.calculus.maxima('f1')
Expand All @@ -419,26 +423,23 @@
"""

import re
from types import FunctionType

from sage.arith.misc import algebraic_dependency
from sage.interfaces.maxima_lib import maxima
from sage.misc.latex import latex
from sage.misc.parser import LookupNameMaker, Parser
from sage.rings.cc import CC
from sage.rings.integer import Integer
from sage.rings.rational_field import QQ
from sage.rings.real_double import RealDoubleElement
from sage.rings.real_mpfr import RR, create_RealNumber
from sage.rings.cc import CC

from sage.misc.latex import latex
from sage.misc.parser import Parser, LookupNameMaker
from sage.structure.element import Expression
from sage.symbolic.ring import var, SR
from sage.symbolic.symbols import symbol_table
from sage.symbolic.function import Function
from sage.symbolic.function_factory import function_factory
from sage.symbolic.integration.integral import (indefinite_integral,
definite_integral)

from sage.misc.lazy_import import lazy_import
lazy_import('sage.interfaces.maxima_lib', 'maxima')
from types import FunctionType
from sage.symbolic.integration.integral import definite_integral, indefinite_integral
from sage.symbolic.ring import SR, var
from sage.symbolic.symbols import symbol_table


########################################################
Expand Down Expand Up @@ -667,6 +668,7 @@
elif algorithm == 'sympy':
expression,v,a,b = (expr._sympy_() for expr in (expression, v, a, b))
from sympy import summation

from sage.interfaces.sympy import sympy_init
sympy_init()
result = summation(expression, (v, a, b))
Expand Down Expand Up @@ -920,6 +922,7 @@
elif algorithm == 'sympy':
expression,v,a,b = (expr._sympy_() for expr in (expression, v, a, b))
from sympy import product as sproduct

from sage.interfaces.sympy import sympy_init
sympy_init()
result = sproduct(expression, (v, a, b))
Expand Down Expand Up @@ -1674,7 +1677,11 @@
sage: mma_free_limit(e^(-x), x, a=oo) # optional - internet
0
"""
from sage.interfaces.mathematica import request_wolfram_alpha, parse_moutput_from_json, symbolic_expression_from_mathematica_string
from sage.interfaces.mathematica import (

Check warning on line 1680 in src/sage/calculus/calculus.py

View check run for this annotation

Codecov / codecov/patch

src/sage/calculus/calculus.py#L1680

Added line #L1680 was not covered by tests
parse_moutput_from_json,
request_wolfram_alpha,
symbolic_expression_from_mathematica_string,
)
dir_plus = ['plus', '+', 'above', 'right']
dir_minus = ['minus', '-', 'below', 'left']
math_expr = expression._mathematica_init_()
Expand Down Expand Up @@ -1915,6 +1922,7 @@
elif algorithm == 'sympy':
ex_sy, t, s = (expr._sympy_() for expr in (ex, t, s))
from sympy import laplace_transform

from sage.interfaces.sympy import sympy_init
sympy_init()
result = laplace_transform(ex_sy, t, s)
Expand Down Expand Up @@ -2100,6 +2108,7 @@
elif algorithm == 'sympy':
ex_sy, s, t = (expr._sympy_() for expr in (ex, s, t))
from sympy import inverse_laplace_transform

from sage.interfaces.sympy import sympy_init
sympy_init()
result = inverse_laplace_transform(ex_sy, s, t)
Expand Down Expand Up @@ -2460,10 +2469,12 @@

Make sure that we don't accidentally pick up variables in the maxima namespace (:issue:`8734`)::

sage: sage.calculus.calculus.maxima('my_new_var : 2')
sage: maxima('my_new_var : 2')
2
sage: var('my_new_var').full_simplify()
my_new_var
sage: maxima('kill(my_new_var)')
done

ODE solution constants are treated differently (:issue:`16007`)::

Expand Down
21 changes: 9 additions & 12 deletions src/sage/calculus/desolvers.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,19 +71,15 @@
# https://www.gnu.org/licenses/
##########################################################################

import shutil
import os
import shutil

from sage.interfaces.maxima import Maxima
from sage.calculus.functional import diff
from sage.interfaces.maxima_lib import maxima
from sage.misc.functional import N
from sage.rings.real_mpfr import RealField
from sage.structure.element import Expression

from .functional import diff


maxima = Maxima()


def fricas_desolve(de, dvar, ics, ivar):
r"""
Expand Down Expand Up @@ -156,8 +152,8 @@
[x(t) == cos(t)^2 + sin(t)^2 + 2*sin(t), y(t) == -2*cos(t) + 1]
"""
from sage.interfaces.fricas import fricas
from sage.symbolic.ring import SR
from sage.symbolic.relation import solve
from sage.symbolic.ring import SR

Check warning on line 156 in src/sage/calculus/desolvers.py

View check run for this annotation

Codecov / codecov/patch

src/sage/calculus/desolvers.py#L156

Added line #L156 was not covered by tests
ops = [dvar.operator() for dvar in dvars]
y = fricas(des).solve(ops, ivar).sage()
basis = y["basis"]
Expand Down Expand Up @@ -1364,9 +1360,9 @@
return plot_slope_field(de, (ivar, XMIN, XMAX), (dvar, YMIN, YMAX)) + R

if not (isinstance(dvar, Expression) and dvar.is_symbol()):
from sage.symbolic.ring import SR
from sage.calculus.all import diff
from sage.symbolic.relation import solve
from sage.symbolic.ring import SR
if isinstance(de, Expression) and de.is_relational():
de = de.lhs() - de.rhs()
# consider to add warning if the solution is not unique
Expand Down Expand Up @@ -1614,8 +1610,9 @@
"""

from scipy.integrate import odeint
from sage.ext.fast_eval import fast_float

from sage.calculus.functions import jacobian
from sage.ext.fast_eval import fast_float

def desolve_odeint_inner(ivar):
# one-dimensional systems:
Expand Down Expand Up @@ -1838,9 +1835,9 @@
import subprocess
if subprocess.call('command -v gcc', shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE):
raise RuntimeError('Unable to run because gcc cannot be found')
from sage.interfaces.tides import genfiles_mpfr
from sage.functions.other import ceil
from sage.functions.log import log
from sage.functions.other import ceil
from sage.interfaces.tides import genfiles_mpfr

Check warning on line 1840 in src/sage/calculus/desolvers.py

View check run for this annotation

Codecov / codecov/patch

src/sage/calculus/desolvers.py#L1839-L1840

Added lines #L1839 - L1840 were not covered by tests
from sage.misc.temporary_file import tmp_dir
tempdir = tmp_dir()
intfile = os.path.join(tempdir, 'integrator.c')
Expand Down
3 changes: 3 additions & 0 deletions src/sage/categories/pushout.py
Original file line number Diff line number Diff line change
Expand Up @@ -3936,6 +3936,7 @@ def __init__(self, box):
TESTS::

sage: from sage.categories.pushout import BlackBoxConstructionFunctor
sage: from sage.interfaces.maxima_lib import maxima
sage: FG = BlackBoxConstructionFunctor(gap)
sage: FM = BlackBoxConstructionFunctor(maxima) # needs sage.symbolic
sage: FM == FG # needs sage.libs.gap sage.symbolic
Expand Down Expand Up @@ -3967,6 +3968,7 @@ def __eq__(self, other):
TESTS::

sage: from sage.categories.pushout import BlackBoxConstructionFunctor
sage: from sage.interfaces.maxima_lib import maxima
sage: FG = BlackBoxConstructionFunctor(gap)
sage: FM = BlackBoxConstructionFunctor(maxima) # needs sage.symbolic
sage: FM == FG # indirect doctest # needs sage.libs.gap sage.symbolic
Expand All @@ -3986,6 +3988,7 @@ def __ne__(self, other):
EXAMPLES::

sage: from sage.categories.pushout import BlackBoxConstructionFunctor
sage: from sage.interfaces.maxima_lib import maxima
sage: FG = BlackBoxConstructionFunctor(gap)
sage: FM = BlackBoxConstructionFunctor(maxima) # needs sage.symbolic
sage: FM != FG # indirect doctest # needs sage.libs.gap sage.symbolic
Expand Down
1 change: 0 additions & 1 deletion src/sage/features/sagemath.py
Original file line number Diff line number Diff line change
Expand Up @@ -1140,7 +1140,6 @@ def __init__(self):
PythonModule('sage.interfaces.maple'),
PythonModule('sage.interfaces.mathematica'),
PythonModule('sage.interfaces.mathics'),
PythonModule('sage.interfaces.maxima'),
PythonModule('sage.interfaces.maxima_abstract'),
PythonModule('sage.interfaces.maxima_lib'),
PythonModule('sage.interfaces.qepcad'),
Expand Down
9 changes: 4 additions & 5 deletions src/sage/functions/orthogonal_polys.py
Original file line number Diff line number Diff line change
Expand Up @@ -396,13 +396,12 @@
import warnings

import sage.rings.abc

from sage.arith.misc import rising_factorial
from sage.misc.lazy_import import lazy_import
from sage.rings.integer_ring import ZZ
from sage.rings.rational_field import QQ
from sage.symbolic.function import BuiltinFunction, GinacFunction
from sage.structure.element import Expression, parent
from sage.symbolic.function import BuiltinFunction, GinacFunction

lazy_import('sage.functions.other', ['factorial', 'binomial'])

Expand Down Expand Up @@ -2446,8 +2445,8 @@ def _eval_(self, n, x, *args, **kwds):
sage: laguerre(-9,2) # needs sage.symbolic
66769/315*e^2
"""
from sage.rings.integer import Integer
from sage.functions.log import exp
from sage.rings.integer import Integer
ret = self._eval_special_values_(n, x)
if ret is not None:
return ret
Expand Down Expand Up @@ -2567,7 +2566,7 @@ def __init__(self):
sage: maxima(gen_laguerre(1, 2, x, hold=True))
3*(1-_SAGE_VAR_x/3)
sage: maxima(gen_laguerre(n, a, gen_laguerre(n, a, x)))
gen_laguerre(_SAGE_VAR_n,_SAGE_VAR_a, gen_laguerre(_SAGE_VAR_n,_SAGE_VAR_a,_SAGE_VAR_x))
gen_laguerre(_SAGE_VAR_n,_SAGE_VAR_a,gen_laguerre(_SAGE_VAR_n,_SAGE_VAR_a,_SAGE_VAR_x))

TESTS::

Expand Down Expand Up @@ -2916,8 +2915,8 @@ def _eval_(self, n, x, b, c, *args, **kwds):
if kwds.get('hold', False):
return None
if n not in ZZ or n < 0:
from sage.functions.hypergeometric import hypergeometric
from sage.functions.gamma import gamma
from sage.functions.hypergeometric import hypergeometric
return gamma(b + n) / gamma(b) * hypergeometric([-n, -x], [b], 1 - 1/c)
try:
return self.eval_formula(n, x, b, c)
Expand Down
8 changes: 1 addition & 7 deletions src/sage/interfaces/all.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
# interfaces to other interpreters

# import problems
try:
# from maxima_lib import maxima_lib
from sage.interfaces.maxima import maxima, Maxima
except ImportError:
pass

from sage.misc.lazy_import import lazy_import

lazy_import('sage.interfaces.maxima_lib', 'maxima')
lazy_import('sage.interfaces.sage0', ['sage0', 'sage0_version', 'Sage'])
lazy_import('sage.interfaces.axiom', ['Axiom', 'axiom'])
lazy_import('sage.interfaces.ecm', ['ECM', 'ecm'])
Expand Down
Loading
Loading