From f6f4e40843a17e59f9880cf19fed929e9732b6e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Chapoton?= Date: Sun, 23 Apr 2023 17:26:32 +0200 Subject: [PATCH 01/10] fix the linter once more --- src/sage/rings/real_double.pyx | 2 +- src/sage/rings/real_mpfr.pyx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/sage/rings/real_double.pyx b/src/sage/rings/real_double.pyx index 72bb242078d..21a2f293ee9 100644 --- a/src/sage/rings/real_double.pyx +++ b/src/sage/rings/real_double.pyx @@ -1522,7 +1522,7 @@ cdef class RealDoubleElement(FieldElement): def round(self): """ Round ``self`` to the nearest integer. - + This uses the convention of rounding half to even (i.e., if the fractional part of ``self`` is `0.5`, then it is rounded to the nearest even integer). diff --git a/src/sage/rings/real_mpfr.pyx b/src/sage/rings/real_mpfr.pyx index 0dd8adb3040..c90469b6549 100644 --- a/src/sage/rings/real_mpfr.pyx +++ b/src/sage/rings/real_mpfr.pyx @@ -2992,7 +2992,7 @@ cdef class RealNumber(sage.structure.element.RingElement): """ Round ``self`` to the nearest representable integer, rounding halfway cases away from zero. - + .. NOTE:: The rounding mode of the parent field does not affect the result. From 892cbe2ce799c52bde2340ab6cbe40d8fb9647ab Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Fri, 12 Nov 2021 21:33:39 -0500 Subject: [PATCH 02/10] Trac #32867: don't export MAXIMA_PREFIX. This should work automatically, and the previous behavior is incorrect if we intend to use the system copy of maxima. --- src/bin/sage-env | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/bin/sage-env b/src/bin/sage-env index a7da60df28f..13b54fa7e92 100644 --- a/src/bin/sage-env +++ b/src/bin/sage-env @@ -440,9 +440,6 @@ if [ -d "$DOT_SAGE" ] ; then fi fi -if [ -n "$SAGE_LOCAL" ]; then - export MAXIMA_PREFIX="$SAGE_LOCAL" -fi export MAXIMA_USERDIR="$DOT_SAGE/maxima" if [ -n "$SAGE_LOCAL" ]; then From 1cfec18653d3651c47931cd907a7a55382274bb6 Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Fri, 12 Nov 2021 20:51:28 -0500 Subject: [PATCH 03/10] Trac #32867: new spkg-configure.m4 for maxima. This new spkg-configure.m4 checks for both a "maxima" executable, and the usability of a "maxima" package by ECL. (The latter requires a patched maxima until a new release with commit a0d7a43e523 is made.) Notably absent for the moment is a version check, but that should be okay: at the moment, the only system copies of maxima that support being used as an ECL library are those that are patched, and the only reason to patch them is if you intend to use them with SageMath. So in short, if a distro patches their maxima to use it with sage, we expect it to work with sage. This commit also moves the SAGE_MAXIMA_FAS variable handling from ECL's spkg-configure.m4 to maxima's (where it would have belonged in the first place, if maxima had an spkg-configure.m4 at the time.) --- build/pkgs/ecl/spkg-configure.m4 | 5 +---- build/pkgs/maxima/spkg-configure.m4 | 32 +++++++++++++++++++++++++++ pkgs/sage-conf/_sage_conf/_conf.py.in | 6 +++-- 3 files changed, 37 insertions(+), 6 deletions(-) create mode 100644 build/pkgs/maxima/spkg-configure.m4 diff --git a/build/pkgs/ecl/spkg-configure.m4 b/build/pkgs/ecl/spkg-configure.m4 index ae1e0ac5e1a..7dbcfa6377b 100644 --- a/build/pkgs/ecl/spkg-configure.m4 +++ b/build/pkgs/ecl/spkg-configure.m4 @@ -35,10 +35,7 @@ SAGE_SPKG_CONFIGURE([ecl], [ AC_SUBST(SAGE_ECL_CONFIG, [$ECL_CONFIG]) fi - # Maxima cannot yet be provided by the system, so we always use + # Kenzo cannot yet be provided by the system, so we always use # the SAGE_LOCAL path for now. - AC_SUBST(SAGE_MAXIMA_FAS, ['${prefix}'/lib/ecl/maxima.fas]) - - # Likewise for the optional Kenzo SPKG AC_SUBST(SAGE_KENZO_FAS, ['${prefix}'/lib/ecl/kenzo.fas]) ]) diff --git a/build/pkgs/maxima/spkg-configure.m4 b/build/pkgs/maxima/spkg-configure.m4 new file mode 100644 index 00000000000..57b2bcd2d71 --- /dev/null +++ b/build/pkgs/maxima/spkg-configure.m4 @@ -0,0 +1,32 @@ +SAGE_SPKG_CONFIGURE([maxima], [ + SAGE_SPKG_DEPCHECK([ecl], [ + dnl First check for the "maxima" executable in the user's PATH, because + dnl we still use pexpect to communicate with it in a few places. + AC_PATH_PROG([SAGE_MAXIMA], [maxima]) + AS_IF([test -z "${SAGE_MAXIMA}"], [ + sage_spkg_install_maxima=yes + ],[ + dnl If we have the executable, check also for the ECL library. + AC_MSG_CHECKING([if ECL can "require" the maxima module]) + AS_IF([ecl --eval "(require 'maxima)" --eval "(quit)" \ + >&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD], [ + AC_MSG_RESULT(yes) + ], [ + AC_MSG_RESULT(no) + sage_spkg_install_maxima=yes + ]) + ]) + ]) +],[],[],[ + # post-check + AS_IF([test x$sage_spkg_install_maxima = xyes], [ + dnl Leaving this variable empty will tell sagelib to load + dnl the maxima library (within ECL) by name instead of by + dnl absolute path. + SAGE_MAXIMA='${prefix}'/bin/maxima + SAGE_MAXIMA_FAS='${prefix}'/lib/ecl/maxima.fas + ]) + + AC_SUBST(SAGE_MAXIMA, "${SAGE_MAXIMA}") + AC_SUBST(SAGE_MAXIMA_FAS, "${SAGE_MAXIMA_FAS}") +]) diff --git a/pkgs/sage-conf/_sage_conf/_conf.py.in b/pkgs/sage-conf/_sage_conf/_conf.py.in index d66bdb3d264..f2e197b45ed 100644 --- a/pkgs/sage-conf/_sage_conf/_conf.py.in +++ b/pkgs/sage-conf/_sage_conf/_conf.py.in @@ -9,9 +9,11 @@ VERSION = "@PACKAGE_VERSION@" SAGE_LOCAL = "@prefix@" SAGE_ROOT = "@SAGE_ROOT@" -MAXIMA = "@prefix@/bin/maxima" +# The path to the standalone maxima executable. +MAXIMA = "@SAGE_MAXIMA@".replace('${prefix}', SAGE_LOCAL) -# Delete this line if your ECL can load maxima without further prodding. +# Set this to the empty string if your ECL can load maxima without +# further prodding. MAXIMA_FAS = "@SAGE_MAXIMA_FAS@".replace('${prefix}', SAGE_LOCAL) # Delete this line if your ECL can load Kenzo without further prodding. From 4d5c3b240bef724b7c67e45f4e0d432ca65a4218 Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Sun, 28 Nov 2021 08:22:30 -0500 Subject: [PATCH 04/10] Trac #32867: maxima package information for Cygwin. --- build/pkgs/maxima/distros/cygwin.txt | 1 + 1 file changed, 1 insertion(+) create mode 100644 build/pkgs/maxima/distros/cygwin.txt diff --git a/build/pkgs/maxima/distros/cygwin.txt b/build/pkgs/maxima/distros/cygwin.txt new file mode 100644 index 00000000000..f5fe3fdc6cb --- /dev/null +++ b/build/pkgs/maxima/distros/cygwin.txt @@ -0,0 +1 @@ +maxima From 25fbf6c10d299c48e13e922b85878db6abc54886 Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Thu, 23 Dec 2021 11:55:49 -0500 Subject: [PATCH 05/10] Trac #32867: disable maxima tests that require matrixexp.patch. This patch won't be present in a system copy of maxima (at least for now), so we disable these tests to avoid spurious failures once we start accepting maxima from the system. --- src/sage/calculus/calculus.py | 5 +++-- src/sage/matrix/matrix2.pyx | 5 +++-- src/sage/matrix/matrix_symbolic_dense.pyx | 6 +++--- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/sage/calculus/calculus.py b/src/sage/calculus/calculus.py index dae380180ac..1384c2a1cd2 100644 --- a/src/sage/calculus/calculus.py +++ b/src/sage/calculus/calculus.py @@ -136,10 +136,11 @@ [ 1/2*(e^(2*sqrt(x)) + 1)*e^(x - sqrt(x)) 1/2*(x*e^(2*sqrt(x)) - x)*sqrt(x)*e^(x - sqrt(x))] [ 1/2*(e^(2*sqrt(x)) - 1)*e^(x - sqrt(x))/x^(3/2) 1/2*(e^(2*sqrt(x)) + 1)*e^(x - sqrt(x))] -And complex exponentiation works now:: +Complex exponentiation works, but may require a patched version of +maxima (:trac:`32898`) for now:: sage: M = i*matrix([[pi]]) - sage: e^M + sage: e^M # not tested, requires patched maxima [-1] sage: M = i*matrix([[pi,0],[0,2*pi]]) sage: e^M diff --git a/src/sage/matrix/matrix2.pyx b/src/sage/matrix/matrix2.pyx index e2e6449dfa9..c66e6d1606a 100644 --- a/src/sage/matrix/matrix2.pyx +++ b/src/sage/matrix/matrix2.pyx @@ -15425,9 +15425,10 @@ cdef class Matrix(Matrix1): TESTS: - Check that sparse matrices are handled correctly (:trac:`28935`):: + Sparse matrices are handled correctly (:trac:`28935`), but may + require a patched version of maxima (:trac:`32898`) for now:: - sage: matrix.diagonal([0], sparse=True).exp() + sage: matrix.diagonal([0], sparse=True).exp() # not tested, requires patched maxima [1] sage: matrix.zero(CBF, 2, sparse=True).exp() [1.000000000000000 0] diff --git a/src/sage/matrix/matrix_symbolic_dense.pyx b/src/sage/matrix/matrix_symbolic_dense.pyx index 19ca5c85cb2..58a25e002f6 100644 --- a/src/sage/matrix/matrix_symbolic_dense.pyx +++ b/src/sage/matrix/matrix_symbolic_dense.pyx @@ -402,7 +402,8 @@ cdef class Matrix_symbolic_dense(Matrix_generic_dense): [1/2*(e^(2*x) + 1)*e^(-x) 1/2*(e^(2*x) - 1)*e^(-x)] [1/2*(e^(2*x) - 1)*e^(-x) 1/2*(e^(2*x) + 1)*e^(-x)] - Exp works on 0x0 and 1x1 matrices:: + Exponentiation works on 0x0 and 1x1 matrices, but the 1x1 example + requires a patched version of maxima (:trac:`32898`) for now:: sage: m = matrix(SR,0,[]); m [] @@ -410,7 +411,7 @@ cdef class Matrix_symbolic_dense(Matrix_generic_dense): [] sage: m = matrix(SR,1,[2]); m [2] - sage: m.exp() + sage: m.exp() # not tested, requires patched maxima [e^2] Commuting matrices `m, n` have the property that @@ -451,7 +452,6 @@ cdef class Matrix_symbolic_dense(Matrix_generic_dense): [ 0 1/2*(e^(2*x) + 1)*e^(-x) 1/2*(e^(2*x) - 1)*e^(-x) 0] [ 0 1/2*(e^(2*x) - 1)*e^(-x) 1/2*(e^(2*x) + 1)*e^(-x) 0] [1/2*(e^(2*x) - 1)*e^(-x) 0 0 1/2*(e^(2*x) + 1)*e^(-x)] - """ if not self.is_square(): raise ValueError("exp only defined on square matrices") From 2b200334df2f2ced4ff0af25c3c2708a9f0a4c65 Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Thu, 23 Dec 2021 11:58:11 -0500 Subject: [PATCH 06/10] Trac #32867: add maxima package information for Gentoo. --- build/pkgs/maxima/distros/gentoo.txt | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 build/pkgs/maxima/distros/gentoo.txt diff --git a/build/pkgs/maxima/distros/gentoo.txt b/build/pkgs/maxima/distros/gentoo.txt new file mode 100644 index 00000000000..85fb33f1610 --- /dev/null +++ b/build/pkgs/maxima/distros/gentoo.txt @@ -0,0 +1,2 @@ +sci-mathematics/maxima[ecls] + From 32b64c114cd1dcf50f46a5f7e001d09bc8bac275 Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Tue, 15 Mar 2022 12:27:49 -0400 Subject: [PATCH 07/10] Trac #32867: don't set a heap limit for the pexpect maxima. We have some old code and an old test for a memory limit that was present in ECL 12 years ago, worked around in ticket 6772. The memory limit is no longer in place, and would not have applied to a non-ECL maxima from the system anyway. Since the test itself is purposely wasteful (to ensure that we can use lots of RAM), we take this opportunity to remove it and speed up the test suite a bit. --- src/sage/interfaces/maxima.py | 8 -------- 1 file changed, 8 deletions(-) diff --git a/src/sage/interfaces/maxima.py b/src/sage/interfaces/maxima.py index 27b1e98a6ac..4829560f98b 100644 --- a/src/sage/interfaces/maxima.py +++ b/src/sage/interfaces/maxima.py @@ -622,11 +622,6 @@ def _start(self): sage: m.is_running() True - Test that we can use more than 256MB RAM (see :trac:`6772`):: - - sage: a = maxima(10)^(10^5) - sage: b = a^600 # long time -- about 10-15 seconds - """ Expect._start(self) self._sendline(r":lisp (defun tex-derivative (x l r) (tex (if $derivabbrev (tex-dabbrev x) (tex-d x '\\partial)) l r lop rop ))") @@ -634,9 +629,6 @@ def _start(self): # Don't use ! for factorials (#11539) self._sendline(":lisp (remprop 'mfactorial 'grind)") - # Remove limit on the max heapsize (since otherwise it defaults - # to 256MB with ECL). - self._sendline(":lisp (ext:set-limit 'ext:heap-size 0)") self._eval_line('0;') # set random seed From 7a30f8f261e6f4c22ca8b6eecfd879bdf62d4dce Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Thu, 31 Mar 2022 17:49:08 -0400 Subject: [PATCH 08/10] Trac #32867: don't require pexpect maxima to live in a "/bin" directory. This just fixes a test. The problem was noticed on Arch where, due to some other circumstances, maxima was executed from within /usr/sbin. But all we know for sure is that maxima will live in PATH. So we modify the test to look only for "maxima", and not its parent directory. --- src/sage/interfaces/expect.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sage/interfaces/expect.py b/src/sage/interfaces/expect.py index 68ae715e4c3..84adf0341b5 100644 --- a/src/sage/interfaces/expect.py +++ b/src/sage/interfaces/expect.py @@ -620,7 +620,7 @@ def quit(self, verbose=False): sage: a = maxima('y') sage: maxima.quit(verbose=True) - Exiting Maxima with PID ... running .../bin/maxima... + Exiting Maxima with PID ... running ...maxima... sage: a._check_valid() Traceback (most recent call last): ... From 3b65c55b9236849e5f499cbada949d423d11a77e Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Fri, 8 Apr 2022 14:46:48 -0400 Subject: [PATCH 09/10] Trac #32867: update package information in distros/arch.txt. The ECL library is now contained in a separate maxima-fas package that will pull in maxima itself. --- build/pkgs/maxima/distros/arch.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/pkgs/maxima/distros/arch.txt b/build/pkgs/maxima/distros/arch.txt index 6400290f44d..6ac052fa62b 100644 --- a/build/pkgs/maxima/distros/arch.txt +++ b/build/pkgs/maxima/distros/arch.txt @@ -1 +1 @@ -maxima-ecl +maxima-fas From ed729a925a6ce4c4da3d4b09e3271092aa69ac50 Mon Sep 17 00:00:00 2001 From: Dima Pasechnik Date: Sat, 6 May 2023 18:25:02 +0100 Subject: [PATCH 10/10] add maxima FreeBSD package info --- build/pkgs/maxima/distros/freebsd.txt | 1 + 1 file changed, 1 insertion(+) create mode 100644 build/pkgs/maxima/distros/freebsd.txt diff --git a/build/pkgs/maxima/distros/freebsd.txt b/build/pkgs/maxima/distros/freebsd.txt new file mode 100644 index 00000000000..766a71b5074 --- /dev/null +++ b/build/pkgs/maxima/distros/freebsd.txt @@ -0,0 +1 @@ +math/maxima