diff --git a/.github/workflows/ci-meson.yml b/.github/workflows/ci-meson.yml
index 41e5f7f5ff8..e777386fcfe 100644
--- a/.github/workflows/ci-meson.yml
+++ b/.github/workflows/ci-meson.yml
@@ -47,7 +47,7 @@ jobs:
key: ${{ runner.os }}-meson-${{ matrix.python }}
- name: Setup Conda environment
- uses: conda-incubator/setup-miniconda@v2
+ uses: conda-incubator/setup-miniconda@v3
with:
python-version: ${{ matrix.python }}
miniforge-version: latest
diff --git a/CITATION.cff b/CITATION.cff
index 7f17ed5c0d8..ae97bd81ee5 100644
--- a/CITATION.cff
+++ b/CITATION.cff
@@ -4,8 +4,8 @@ title: SageMath
abstract: SageMath is a free open-source mathematics software system.
authors:
- name: "The SageMath Developers"
-version: 10.6.beta1
+version: 10.6.beta2
doi: 10.5281/zenodo.8042260
-date-released: 2024-12-15
+date-released: 2024-12-22
repository-code: "https://github.com/sagemath/sage"
url: "https://www.sagemath.org/"
diff --git a/VERSION.txt b/VERSION.txt
index 6af82e4b429..a5da045ce22 100644
--- a/VERSION.txt
+++ b/VERSION.txt
@@ -1 +1 @@
-SageMath version 10.6.beta1, Release Date: 2024-12-15
+SageMath version 10.6.beta2, Release Date: 2024-12-22
diff --git a/build/bin/sage-dist-helpers b/build/bin/sage-dist-helpers
index 520b6ceec5a..f8d07741612 100644
--- a/build/bin/sage-dist-helpers
+++ b/build/bin/sage-dist-helpers
@@ -71,10 +71,9 @@
#
# - sdh_cmake [...]
#
-# Runs `cmake` in the current directory with the given arguments, as well as
-# additional arguments passed to cmake (assuming packages are using the
-# GNUInstallDirs module) so that `CMAKE_INSTALL_PREFIX` and
-# `CMAKE_INSTALL_LIBDIR` are set correctly.
+# Runs `cmake` with the given arguments, as well as additional arguments
+# (assuming packages are using the GNUInstallDirs module) so that
+# `CMAKE_INSTALL_PREFIX` and `CMAKE_INSTALL_LIBDIR` are set correctly.
#
# - sdh_install [-T] SRC [SRC...] DEST
#
@@ -416,9 +415,9 @@ sdh_pip_uninstall() {
sdh_cmake() {
echo "Configuring $PKG_NAME with cmake"
- cmake . -DCMAKE_INSTALL_PREFIX="${SAGE_INST_LOCAL}" \
- -DCMAKE_INSTALL_LIBDIR=lib \
- "$@"
+ cmake -DCMAKE_INSTALL_PREFIX="${SAGE_INST_LOCAL}" \
+ -DCMAKE_INSTALL_LIBDIR=lib \
+ "$@"
if [ $? -ne 0 ]; then
if [ -f "$(pwd)/CMakeFiles/CMakeOutput.log" ]; then
sdh_die <<_EOF_
diff --git a/build/pkgs/bliss/spkg-install.in b/build/pkgs/bliss/spkg-install.in
index b988d6262ce..b203f30dcab 100644
--- a/build/pkgs/bliss/spkg-install.in
+++ b/build/pkgs/bliss/spkg-install.in
@@ -3,6 +3,6 @@ if [ "$UNAME" = "Darwin" ]; then
export LDFLAGS
fi
cd src
-sdh_cmake -DUSE_GMP=OFF -DCMAKE_VERBOSE_MAKEFILE=ON
+sdh_cmake -DUSE_GMP=OFF -DCMAKE_VERBOSE_MAKEFILE=ON .
sdh_make
sdh_make_install
diff --git a/build/pkgs/ccache/checksums.ini b/build/pkgs/ccache/checksums.ini
index 2b4b1895243..23eadcfc9b7 100644
--- a/build/pkgs/ccache/checksums.ini
+++ b/build/pkgs/ccache/checksums.ini
@@ -1,3 +1,4 @@
-tarball=ccache-VERSION.tar.bz2
-sha1=3653e0765f01697c449f7026c479fbd9526323a7
-sha256=fa9d7f38367431bc86b19ad107d709ca7ecf1574fdacca01698bdf0a47cd8567
+tarball=ccache-VERSION.tar.xz
+sha1=cff97f7592f5042eb43cb54a6d12a1ce7e49da62
+sha256=c0b85ddfc1a3e77b105ec9ada2d24aad617fa0b447c6a94d55890972810f0f5a
+upstream_url=https://github.com/ccache/ccache/releases/download/vVERSION/ccache-VERSION.tar.xz
diff --git a/build/pkgs/ccache/dependencies b/build/pkgs/ccache/dependencies
index a1eb8a80d3d..e1c0b124beb 100644
--- a/build/pkgs/ccache/dependencies
+++ b/build/pkgs/ccache/dependencies
@@ -1,4 +1,4 @@
-zlib
+cmake xz
----------
All lines of this file are ignored except the first.
diff --git a/build/pkgs/ccache/distros/arch.txt b/build/pkgs/ccache/distros/arch.txt
new file mode 100644
index 00000000000..812b9efc0c5
--- /dev/null
+++ b/build/pkgs/ccache/distros/arch.txt
@@ -0,0 +1 @@
+ccache
diff --git a/build/pkgs/ccache/package-version.txt b/build/pkgs/ccache/package-version.txt
index a0891f563f3..0216ba38478 100644
--- a/build/pkgs/ccache/package-version.txt
+++ b/build/pkgs/ccache/package-version.txt
@@ -1 +1 @@
-3.3.4
+4.10.2
diff --git a/build/pkgs/ccache/patches/01-apple-gcc-id.patch b/build/pkgs/ccache/patches/01-apple-gcc-id.patch
deleted file mode 100644
index fec64b61d85..00000000000
--- a/build/pkgs/ccache/patches/01-apple-gcc-id.patch
+++ /dev/null
@@ -1,15 +0,0 @@
-diff --git a/test.sh b/test.sh
-index b4c95b1..e51b4bc 100755
---- a/test.sh
-+++ b/test.sh
-@@ -3354,6 +3354,10 @@ case $compiler_version in
- *clang*)
- COMPILER_TYPE_CLANG=true
- ;;
-+ *Xcode.app*)
-+# /usr/bin/gcc on OS X which is a front end to clang doesn't have gcc or clang in the first line.
-+ COMPILER_TYPE_CLANG=true
-+ ;;
- *)
- echo "WARNING: Compiler $COMPILER not supported (version: $compiler_version) -- not running tests" >&2
- exit 0
diff --git a/build/pkgs/ccache/spkg-install.in b/build/pkgs/ccache/spkg-install.in
index 3ed82ae521c..6e7bcf1fc55 100644
--- a/build/pkgs/ccache/spkg-install.in
+++ b/build/pkgs/ccache/spkg-install.in
@@ -1,14 +1,14 @@
cd src
-# Use newer version of config.guess and config.sub (see Issue #23710)
-cp "$SAGE_ROOT"/config/config.* .
-
-export CPPFLAGS="-I$SAGE_LOCAL/include $CPPFLAGS"
-sdh_configure
+mkdir build
+cd build
+sdh_cmake -DCMAKE_BUILD_TYPE=Release \
+ -DENABLE_TESTING=OFF \
+ -DREDIS_STORAGE_BACKEND=OFF \
+ ..
sdh_make
sdh_make_install
-
set -e
mkdir -p "$SAGE_LOCAL/libexec/ccache"
@@ -21,4 +21,4 @@ ln -sf ../../bin/ccache "$SAGE_LOCAL/libexec/ccache/clang++"
# Copy a reasonable default configuration for Sage
# (cache size of 4G and compression enabled)
-cp -p ../ccache.conf "$SAGE_LOCAL/etc"
+cp -p ../../ccache.conf "$SAGE_LOCAL/etc"
diff --git a/build/pkgs/cmake/checksums.ini b/build/pkgs/cmake/checksums.ini
index 477a967711a..812e28398b0 100644
--- a/build/pkgs/cmake/checksums.ini
+++ b/build/pkgs/cmake/checksums.ini
@@ -1,4 +1,4 @@
tarball=cmake-VERSION.tar.gz
-sha1=05de9ac807fefeb2a36ed5e8fcea376a00dd3d57
-sha256=fece24563f697870fbb982ea8bf17482c9d5f855d8c9bf0b82463d76c9e8d0cc
+sha1=b87bd9de209a60d7bc81b8fed594ea26adb4f716
+sha256=42abb3f48f37dbd739cdfeb19d3712db0c5935ed5c2aef6c340f9ae9114238a2
upstream_url=https://github.com/Kitware/CMake/releases/download/vVERSION/cmake-VERSION.tar.gz
diff --git a/build/pkgs/cmake/package-version.txt b/build/pkgs/cmake/package-version.txt
index f641ba7ef04..4464a71f413 100644
--- a/build/pkgs/cmake/package-version.txt
+++ b/build/pkgs/cmake/package-version.txt
@@ -1 +1 @@
-3.27.8
+3.31.2
diff --git a/build/pkgs/configure/checksums.ini b/build/pkgs/configure/checksums.ini
index f2f6667ba09..e337163151d 100644
--- a/build/pkgs/configure/checksums.ini
+++ b/build/pkgs/configure/checksums.ini
@@ -1,3 +1,3 @@
tarball=configure-VERSION.tar.gz
-sha1=ebc4bd50c332f06ad5b2a4ce6217ec65790655ab
-sha256=a2fa7623b406a7937ebfbe3cc6d9e17bcf0c219dec2646320b7266326d789b56
+sha1=a03b8a505678cba0d652514d739bd32eb30bb925
+sha256=6525b44fea6b9d0238ca4790e8be5168e8d08c350787704a59ada9b6075a1f0f
diff --git a/build/pkgs/configure/package-version.txt b/build/pkgs/configure/package-version.txt
index 2ae68fc2cca..84217b4b61b 100644
--- a/build/pkgs/configure/package-version.txt
+++ b/build/pkgs/configure/package-version.txt
@@ -1 +1 @@
-a72ae6d615ddfd3e49b36c200aaf14c24a265916
+291e54bf234b1753909f22a043e91a4a639693c1
diff --git a/build/pkgs/dsdp/spkg-install.in b/build/pkgs/dsdp/spkg-install.in
index 5d0ecadf030..238cc83b279 100644
--- a/build/pkgs/dsdp/spkg-install.in
+++ b/build/pkgs/dsdp/spkg-install.in
@@ -5,6 +5,7 @@ sdh_cmake -DCMAKE_BUILD_TYPE=Release \
-DBUILD_SHARED_LIBS=ON \
-DBLA_VENDOR=OpenBLAS \
-DBLAS_LIBRARIES="$(pkg-config --libs blas)" \
- -DLAPACK_LIBRARIES="$(pkg-config --libs lapack)"
+ -DLAPACK_LIBRARIES="$(pkg-config --libs lapack)" \
+ .
sdh_make
sdh_make_install
diff --git a/build/pkgs/primecount/spkg-install.in b/build/pkgs/primecount/spkg-install.in
index 7589fad8cb9..19b88753127 100644
--- a/build/pkgs/primecount/spkg-install.in
+++ b/build/pkgs/primecount/spkg-install.in
@@ -36,6 +36,7 @@ sdh_cmake -DCMAKE_VERBOSE_MAKEFILE=ON \
-DCMAKE_FIND_ROOT_PATH_MODE_LIBRARY=BOTH \
-DCMAKE_INSTALL_PREFIX=$SAGE_LOCAL \
-DWITH_POPCNT=OFF \
+ . \
&& sdh_make_install
}
diff --git a/build/pkgs/primesieve/spkg-install.in b/build/pkgs/primesieve/spkg-install.in
index c7669a664e9..52968c86587 100644
--- a/build/pkgs/primesieve/spkg-install.in
+++ b/build/pkgs/primesieve/spkg-install.in
@@ -9,6 +9,7 @@ sdh_cmake -DCMAKE_VERBOSE_MAKEFILE=ON \
-DBUILD_STATIC_LIBS=OFF \
-DBUILD_SHARED_LIBS=ON \
-DBUILD_TESTS=ON \
- ${EXTRA_OPTS}
+ ${EXTRA_OPTS} \
+ .
sdh_make_install
diff --git a/build/pkgs/qhull/spkg-install.in b/build/pkgs/qhull/spkg-install.in
index c3df534ad86..e649712ac43 100644
--- a/build/pkgs/qhull/spkg-install.in
+++ b/build/pkgs/qhull/spkg-install.in
@@ -1,7 +1,8 @@
cd src/
sdh_cmake -DCMAKE_VERBOSE_MAKEFILE=ON \
- -DLIB_INSTALL_DIR="${SAGE_LOCAL}"/lib
+ -DLIB_INSTALL_DIR="${SAGE_LOCAL}"/lib \
+ .
sdh_make
diff --git a/build/pkgs/sage_conf/version_requirements.txt b/build/pkgs/sage_conf/version_requirements.txt
index 5fe4d966040..dac4c2ff0f5 100644
--- a/build/pkgs/sage_conf/version_requirements.txt
+++ b/build/pkgs/sage_conf/version_requirements.txt
@@ -1,2 +1,2 @@
# This file is updated on every release by the sage-update-version script
-sage-conf ~= 10.6b1
+sage-conf ~= 10.6b2
diff --git a/build/pkgs/sage_docbuild/version_requirements.txt b/build/pkgs/sage_docbuild/version_requirements.txt
index 8c3a08af6ba..1042c4d84b3 100644
--- a/build/pkgs/sage_docbuild/version_requirements.txt
+++ b/build/pkgs/sage_docbuild/version_requirements.txt
@@ -1,2 +1,2 @@
# This file is updated on every release by the sage-update-version script
-sage-docbuild ~= 10.6b1
+sage-docbuild ~= 10.6b2
diff --git a/build/pkgs/sage_setup/version_requirements.txt b/build/pkgs/sage_setup/version_requirements.txt
index 20373e5b24b..be5c8645b19 100644
--- a/build/pkgs/sage_setup/version_requirements.txt
+++ b/build/pkgs/sage_setup/version_requirements.txt
@@ -1,2 +1,2 @@
# This file is updated on every release by the sage-update-version script
-sage-setup ~= 10.6b1
+sage-setup ~= 10.6b2
diff --git a/build/pkgs/sage_sws2rst/version_requirements.txt b/build/pkgs/sage_sws2rst/version_requirements.txt
index 75d2dea8555..734ca51955f 100644
--- a/build/pkgs/sage_sws2rst/version_requirements.txt
+++ b/build/pkgs/sage_sws2rst/version_requirements.txt
@@ -1,2 +1,2 @@
# This file is updated on every release by the sage-update-version script
-sage-sws2rst ~= 10.6b1
+sage-sws2rst ~= 10.6b2
diff --git a/build/pkgs/sagelib/version_requirements.txt b/build/pkgs/sagelib/version_requirements.txt
index b9b66b303ce..9db5148c938 100644
--- a/build/pkgs/sagelib/version_requirements.txt
+++ b/build/pkgs/sagelib/version_requirements.txt
@@ -1,2 +1,2 @@
# This file is updated on every release by the sage-update-version script
-sagemath-standard ~= 10.6b1
+sagemath-standard ~= 10.6b2
diff --git a/build/pkgs/sagemath_bliss/version_requirements.txt b/build/pkgs/sagemath_bliss/version_requirements.txt
index 66cfe981b11..bcd0492a487 100644
--- a/build/pkgs/sagemath_bliss/version_requirements.txt
+++ b/build/pkgs/sagemath_bliss/version_requirements.txt
@@ -1,2 +1,2 @@
# This file is updated on every release by the sage-update-version script
-sagemath-bliss ~= 10.6b1
+sagemath-bliss ~= 10.6b2
diff --git a/build/pkgs/sagemath_categories/version_requirements.txt b/build/pkgs/sagemath_categories/version_requirements.txt
index 012ced666ae..71d3e4365fb 100644
--- a/build/pkgs/sagemath_categories/version_requirements.txt
+++ b/build/pkgs/sagemath_categories/version_requirements.txt
@@ -1,2 +1,2 @@
# This file is updated on every release by the sage-update-version script
-sagemath-categories ~= 10.6b1
+sagemath-categories ~= 10.6b2
diff --git a/build/pkgs/sagemath_coxeter3/version_requirements.txt b/build/pkgs/sagemath_coxeter3/version_requirements.txt
index d0efaa88af2..fc343e41411 100644
--- a/build/pkgs/sagemath_coxeter3/version_requirements.txt
+++ b/build/pkgs/sagemath_coxeter3/version_requirements.txt
@@ -1,2 +1,2 @@
# This file is updated on every release by the sage-update-version script
-sagemath-coxeter3 ~= 10.6b1
+sagemath-coxeter3 ~= 10.6b2
diff --git a/build/pkgs/sagemath_environment/version_requirements.txt b/build/pkgs/sagemath_environment/version_requirements.txt
index 6cae42add68..837e63fe820 100644
--- a/build/pkgs/sagemath_environment/version_requirements.txt
+++ b/build/pkgs/sagemath_environment/version_requirements.txt
@@ -1,2 +1,2 @@
# This file is updated on every release by the sage-update-version script
-sagemath-environment ~= 10.6b1
+sagemath-environment ~= 10.6b2
diff --git a/build/pkgs/sagemath_mcqd/version_requirements.txt b/build/pkgs/sagemath_mcqd/version_requirements.txt
index 17c1fefc2b9..21dcc676acf 100644
--- a/build/pkgs/sagemath_mcqd/version_requirements.txt
+++ b/build/pkgs/sagemath_mcqd/version_requirements.txt
@@ -1,2 +1,2 @@
# This file is updated on every release by the sage-update-version script
-sagemath-mcqd ~= 10.6b1
+sagemath-mcqd ~= 10.6b2
diff --git a/build/pkgs/sagemath_meataxe/version_requirements.txt b/build/pkgs/sagemath_meataxe/version_requirements.txt
index 2dc47f93620..510a8736cf5 100644
--- a/build/pkgs/sagemath_meataxe/version_requirements.txt
+++ b/build/pkgs/sagemath_meataxe/version_requirements.txt
@@ -1,2 +1,2 @@
# This file is updated on every release by the sage-update-version script
-sagemath-meataxe ~= 10.6b1
+sagemath-meataxe ~= 10.6b2
diff --git a/build/pkgs/sagemath_objects/version_requirements.txt b/build/pkgs/sagemath_objects/version_requirements.txt
index aa457cf9337..b5877570307 100644
--- a/build/pkgs/sagemath_objects/version_requirements.txt
+++ b/build/pkgs/sagemath_objects/version_requirements.txt
@@ -1,2 +1,2 @@
# This file is updated on every release by the sage-update-version script
-sagemath-objects ~= 10.6b1
+sagemath-objects ~= 10.6b2
diff --git a/build/pkgs/sagemath_repl/version_requirements.txt b/build/pkgs/sagemath_repl/version_requirements.txt
index d89f0a710d3..8d7fca3395c 100644
--- a/build/pkgs/sagemath_repl/version_requirements.txt
+++ b/build/pkgs/sagemath_repl/version_requirements.txt
@@ -1,2 +1,2 @@
# This file is updated on every release by the sage-update-version script
-sagemath-repl ~= 10.6b1
+sagemath-repl ~= 10.6b2
diff --git a/build/pkgs/sagemath_sirocco/version_requirements.txt b/build/pkgs/sagemath_sirocco/version_requirements.txt
index 3b31a56b658..18111e8fa2d 100644
--- a/build/pkgs/sagemath_sirocco/version_requirements.txt
+++ b/build/pkgs/sagemath_sirocco/version_requirements.txt
@@ -1,2 +1,2 @@
# This file is updated on every release by the sage-update-version script
-sagemath-sirocco ~= 10.6b1
+sagemath-sirocco ~= 10.6b2
diff --git a/build/pkgs/sagemath_tdlib/version_requirements.txt b/build/pkgs/sagemath_tdlib/version_requirements.txt
index a1de5923196..b297935ac75 100644
--- a/build/pkgs/sagemath_tdlib/version_requirements.txt
+++ b/build/pkgs/sagemath_tdlib/version_requirements.txt
@@ -1,2 +1,2 @@
# This file is updated on every release by the sage-update-version script
-sagemath-tdlib ~= 10.6b1
+sagemath-tdlib ~= 10.6b2
diff --git a/build/pkgs/scip/spkg-install.in b/build/pkgs/scip/spkg-install.in
index 69bbdfae266..2ec391fc2bc 100644
--- a/build/pkgs/scip/spkg-install.in
+++ b/build/pkgs/scip/spkg-install.in
@@ -2,16 +2,16 @@ cd src
mkdir build
cd build
sdh_cmake -DCMAKE_INSTALL_LIBDIR=lib \
- -DCMAKE_VERBOSE_MAKEFILE=ON \
- -DCMAKE_BUILD_WITH_INSTALL_NAME_DIR=ON \
- -DGMP_DIR="${SAGE_GMP_PREFIX}" \
- -DReadline_ROOT_DIR=$(pkg-config --variable=prefix readline) \
- -DHistory_ROOT_DIR=$(pkg-config --variable=prefix readline) \
- -DIPOPT=off \
- -DPAPILO=on -DPAPILO_DIR="${SAGE_LOCAL}" \
- -DZIMPL=off \
- -DAMPL=off \
- -DSYM=bliss \
- ..
+ -DCMAKE_VERBOSE_MAKEFILE=ON \
+ -DCMAKE_BUILD_WITH_INSTALL_NAME_DIR=ON \
+ -DGMP_DIR="${SAGE_GMP_PREFIX}" \
+ -DReadline_ROOT_DIR=$(pkg-config --variable=prefix readline) \
+ -DHistory_ROOT_DIR=$(pkg-config --variable=prefix readline) \
+ -DIPOPT=off \
+ -DPAPILO=on -DPAPILO_DIR="${SAGE_LOCAL}" \
+ -DZIMPL=off \
+ -DAMPL=off \
+ -DSYM=bliss \
+ ..
sdh_make
sdh_make_install
diff --git a/build/pkgs/scip_sdp/spkg-install.in b/build/pkgs/scip_sdp/spkg-install.in
index 3a65a004219..bc202b1262b 100644
--- a/build/pkgs/scip_sdp/spkg-install.in
+++ b/build/pkgs/scip_sdp/spkg-install.in
@@ -2,14 +2,14 @@ cd src
mkdir build
cd build
sdh_cmake -DCMAKE_INSTALL_LIBDIR=lib \
- -DCMAKE_VERBOSE_MAKEFILE=ON \
- -DCMAKE_BUILD_WITH_INSTALL_NAME_DIR=ON \
- -DBLA_VENDOR=OpenBLAS \
- -DBLAS_LIBRARIES="$(pkg-config --libs blas)" \
- -DLAPACK_LIBRARIES="$(pkg-config --libs lapack)" \
- -DSCIP_DIR="${SAGE_LOCAL}" \
- -DSYM=bliss \
- -DSDPS=dsdp \
- ..
+ -DCMAKE_VERBOSE_MAKEFILE=ON \
+ -DCMAKE_BUILD_WITH_INSTALL_NAME_DIR=ON \
+ -DBLA_VENDOR=OpenBLAS \
+ -DBLAS_LIBRARIES="$(pkg-config --libs blas)" \
+ -DLAPACK_LIBRARIES="$(pkg-config --libs lapack)" \
+ -DSCIP_DIR="${SAGE_LOCAL}" \
+ -DSYM=bliss \
+ -DSDPS=dsdp \
+ ..
sdh_make
sdh_make_install
diff --git a/build/pkgs/suitesparse/spkg-install.in b/build/pkgs/suitesparse/spkg-install.in
index f7ef16bb48b..cfc8b176d71 100644
--- a/build/pkgs/suitesparse/spkg-install.in
+++ b/build/pkgs/suitesparse/spkg-install.in
@@ -5,7 +5,7 @@ echo "Configuring suitesparse"
# Hopefully these sill be normalised in the future.
# * SUITESPARSE_INCLUDEDIR_POSTFIX sets the subfolder in which to install headers.
# It default to "suitesparse" if not defined, which currently breaks dependencies.
-# * SUITESPARSE_USE_FORTRAN make sure the fortran interface is off. There is trouble when
+# * SUITESPARSE_USE_FORTRAN make sure the fortran interface is off. There is trouble when
# gcc and gfortran version are not matching.
# * SUITESPARSE_ENABLE_PROJECTS semi column separated list of the desired packages. Default is
# all the packages in the suitesparse tarball.
@@ -16,6 +16,7 @@ sdh_cmake -DCMAKE_VERBOSE_MAKEFILE=ON \
-DNSTATIC=ON \
-DSUITESPARSE_USE_FORTRAN=OFF \
-DSUITESPARSE_INCLUDEDIR_POSTFIX="" \
- -DSUITESPARSE_ENABLE_PROJECTS="suitesparse_config;amd;camd;ccolamd;colamd;cholmod;umfpack"
+ -DSUITESPARSE_ENABLE_PROJECTS="suitesparse_config;amd;camd;ccolamd;colamd;cholmod;umfpack" \
+ .
sdh_make_install
diff --git a/build/pkgs/symengine/spkg-install.in b/build/pkgs/symengine/spkg-install.in
index 8eaaf6fbcbe..3e9c4b05fcf 100644
--- a/build/pkgs/symengine/spkg-install.in
+++ b/build/pkgs/symengine/spkg-install.in
@@ -2,18 +2,18 @@ cd src
mkdir build
cd build
sdh_cmake -DCMAKE_PREFIX_PATH="$SAGE_LOCAL" \
- -DWITH_SYMENGINE_THREAD_SAFE=yes \
- -DWITH_ECM=yes \
- -DWITH_FLINT=yes \
- -DWITH_ARB=yes \
- -DWITH_MPFR=yes \
- -DWITH_MPC=yes \
- -DWITH_LLVM=no \
- -DINTEGER_CLASS="flint" \
- -DBUILD_BENCHMARKS=no \
- -DBUILD_SHARED_LIBS=yes \
- -DBUILD_TESTS=yes \
- ..
+ -DWITH_SYMENGINE_THREAD_SAFE=yes \
+ -DWITH_ECM=yes \
+ -DWITH_FLINT=yes \
+ -DWITH_ARB=yes \
+ -DWITH_MPFR=yes \
+ -DWITH_MPC=yes \
+ -DWITH_LLVM=no \
+ -DINTEGER_CLASS="flint" \
+ -DBUILD_BENCHMARKS=no \
+ -DBUILD_SHARED_LIBS=yes \
+ -DBUILD_TESTS=yes \
+ ..
sdh_make
sdh_make install
diff --git a/pkgs/sage-conf/VERSION.txt b/pkgs/sage-conf/VERSION.txt
index 6e3a857d06e..61117e46f91 100644
--- a/pkgs/sage-conf/VERSION.txt
+++ b/pkgs/sage-conf/VERSION.txt
@@ -1 +1 @@
-10.6.beta1
+10.6.beta2
diff --git a/pkgs/sage-conf_conda/VERSION.txt b/pkgs/sage-conf_conda/VERSION.txt
index 6e3a857d06e..61117e46f91 100644
--- a/pkgs/sage-conf_conda/VERSION.txt
+++ b/pkgs/sage-conf_conda/VERSION.txt
@@ -1 +1 @@
-10.6.beta1
+10.6.beta2
diff --git a/pkgs/sage-conf_pypi/VERSION.txt b/pkgs/sage-conf_pypi/VERSION.txt
index 6e3a857d06e..61117e46f91 100644
--- a/pkgs/sage-conf_pypi/VERSION.txt
+++ b/pkgs/sage-conf_pypi/VERSION.txt
@@ -1 +1 @@
-10.6.beta1
+10.6.beta2
diff --git a/pkgs/sage-docbuild/VERSION.txt b/pkgs/sage-docbuild/VERSION.txt
index 6e3a857d06e..61117e46f91 100644
--- a/pkgs/sage-docbuild/VERSION.txt
+++ b/pkgs/sage-docbuild/VERSION.txt
@@ -1 +1 @@
-10.6.beta1
+10.6.beta2
diff --git a/pkgs/sage-setup/VERSION.txt b/pkgs/sage-setup/VERSION.txt
index 6e3a857d06e..61117e46f91 100644
--- a/pkgs/sage-setup/VERSION.txt
+++ b/pkgs/sage-setup/VERSION.txt
@@ -1 +1 @@
-10.6.beta1
+10.6.beta2
diff --git a/pkgs/sage-sws2rst/VERSION.txt b/pkgs/sage-sws2rst/VERSION.txt
index 6e3a857d06e..61117e46f91 100644
--- a/pkgs/sage-sws2rst/VERSION.txt
+++ b/pkgs/sage-sws2rst/VERSION.txt
@@ -1 +1 @@
-10.6.beta1
+10.6.beta2
diff --git a/pkgs/sagemath-bliss/VERSION.txt b/pkgs/sagemath-bliss/VERSION.txt
index 6e3a857d06e..61117e46f91 100644
--- a/pkgs/sagemath-bliss/VERSION.txt
+++ b/pkgs/sagemath-bliss/VERSION.txt
@@ -1 +1 @@
-10.6.beta1
+10.6.beta2
diff --git a/pkgs/sagemath-categories/VERSION.txt b/pkgs/sagemath-categories/VERSION.txt
index 6e3a857d06e..61117e46f91 100644
--- a/pkgs/sagemath-categories/VERSION.txt
+++ b/pkgs/sagemath-categories/VERSION.txt
@@ -1 +1 @@
-10.6.beta1
+10.6.beta2
diff --git a/pkgs/sagemath-coxeter3/VERSION.txt b/pkgs/sagemath-coxeter3/VERSION.txt
index 6e3a857d06e..61117e46f91 100644
--- a/pkgs/sagemath-coxeter3/VERSION.txt
+++ b/pkgs/sagemath-coxeter3/VERSION.txt
@@ -1 +1 @@
-10.6.beta1
+10.6.beta2
diff --git a/pkgs/sagemath-environment/VERSION.txt b/pkgs/sagemath-environment/VERSION.txt
index 6e3a857d06e..61117e46f91 100644
--- a/pkgs/sagemath-environment/VERSION.txt
+++ b/pkgs/sagemath-environment/VERSION.txt
@@ -1 +1 @@
-10.6.beta1
+10.6.beta2
diff --git a/pkgs/sagemath-mcqd/VERSION.txt b/pkgs/sagemath-mcqd/VERSION.txt
index 6e3a857d06e..61117e46f91 100644
--- a/pkgs/sagemath-mcqd/VERSION.txt
+++ b/pkgs/sagemath-mcqd/VERSION.txt
@@ -1 +1 @@
-10.6.beta1
+10.6.beta2
diff --git a/pkgs/sagemath-meataxe/VERSION.txt b/pkgs/sagemath-meataxe/VERSION.txt
index 6e3a857d06e..61117e46f91 100644
--- a/pkgs/sagemath-meataxe/VERSION.txt
+++ b/pkgs/sagemath-meataxe/VERSION.txt
@@ -1 +1 @@
-10.6.beta1
+10.6.beta2
diff --git a/pkgs/sagemath-objects/VERSION.txt b/pkgs/sagemath-objects/VERSION.txt
index 6e3a857d06e..61117e46f91 100644
--- a/pkgs/sagemath-objects/VERSION.txt
+++ b/pkgs/sagemath-objects/VERSION.txt
@@ -1 +1 @@
-10.6.beta1
+10.6.beta2
diff --git a/pkgs/sagemath-repl/VERSION.txt b/pkgs/sagemath-repl/VERSION.txt
index 6e3a857d06e..61117e46f91 100644
--- a/pkgs/sagemath-repl/VERSION.txt
+++ b/pkgs/sagemath-repl/VERSION.txt
@@ -1 +1 @@
-10.6.beta1
+10.6.beta2
diff --git a/pkgs/sagemath-sirocco/VERSION.txt b/pkgs/sagemath-sirocco/VERSION.txt
index 6e3a857d06e..61117e46f91 100644
--- a/pkgs/sagemath-sirocco/VERSION.txt
+++ b/pkgs/sagemath-sirocco/VERSION.txt
@@ -1 +1 @@
-10.6.beta1
+10.6.beta2
diff --git a/pkgs/sagemath-tdlib/VERSION.txt b/pkgs/sagemath-tdlib/VERSION.txt
index 6e3a857d06e..61117e46f91 100644
--- a/pkgs/sagemath-tdlib/VERSION.txt
+++ b/pkgs/sagemath-tdlib/VERSION.txt
@@ -1 +1 @@
-10.6.beta1
+10.6.beta2
diff --git a/src/VERSION.txt b/src/VERSION.txt
index 6e3a857d06e..61117e46f91 100644
--- a/src/VERSION.txt
+++ b/src/VERSION.txt
@@ -1 +1 @@
-10.6.beta1
+10.6.beta2
diff --git a/src/bin/sage-version.sh b/src/bin/sage-version.sh
index 6877ac8ce0a..c21005c7881 100644
--- a/src/bin/sage-version.sh
+++ b/src/bin/sage-version.sh
@@ -4,6 +4,6 @@
# which stops "setup.py develop" from rewriting it as a Python file.
:
# This file is auto-generated by the sage-update-version script, do not edit!
-SAGE_VERSION='10.6.beta1'
-SAGE_RELEASE_DATE='2024-12-15'
-SAGE_VERSION_BANNER='SageMath version 10.6.beta1, Release Date: 2024-12-15'
+SAGE_VERSION='10.6.beta2'
+SAGE_RELEASE_DATE='2024-12-22'
+SAGE_VERSION_BANNER='SageMath version 10.6.beta2, Release Date: 2024-12-22'
diff --git a/src/doc/en/developer/coding_basics.rst b/src/doc/en/developer/coding_basics.rst
index 9b56de46ad0..02936d3e423 100644
--- a/src/doc/en/developer/coding_basics.rst
+++ b/src/doc/en/developer/coding_basics.rst
@@ -82,6 +82,19 @@ In particular,
def SomeIdentityValue(x):
return SomeValue(1)
+.. _section-python-version:
+
+Python Version
+=================
+
+In order to reduce the technical debt of maintaining the project, Sage follows
+the time window-based support policy
+`SPEC 0 — Minimum Supported Dependencies `_
+for Python versions. Accordingly, support for Python versions will be dropped
+3 years after their initial release.
+For the drop schedule of Python versions, see the
+`SPEC 0 `_
+document.
.. _chapter-directory-structure:
diff --git a/src/doc/en/developer/packaging.rst b/src/doc/en/developer/packaging.rst
index 2b6903ca466..cfa6fec89d3 100644
--- a/src/doc/en/developer/packaging.rst
+++ b/src/doc/en/developer/packaging.rst
@@ -497,10 +497,9 @@ should not need to add it yourself.
The following are also available, but rarely used.
-- ``sdh_cmake [...]``: Runs ``cmake`` in the current directory with
- the given arguments, as well as additional arguments passed to
- cmake (assuming packages are using the GNUInstallDirs module) so
- that ``CMAKE_INSTALL_PREFIX`` and ``CMAKE_INSTALL_LIBDIR`` are set
+- ``sdh_cmake [...]``: Runs ``cmake`` with the given arguments, as well as
+ additional arguments (assuming packages are using the GNUInstallDirs module)
+ so that ``CMAKE_INSTALL_PREFIX`` and ``CMAKE_INSTALL_LIBDIR`` are set
correctly.
- ``sdh_preload_lib EXECUTABLE SONAME``: (Linux only -- no-op on other
diff --git a/src/doc/en/installation/meson.rst b/src/doc/en/installation/meson.rst
index a5f9c49d69e..196ecc02597 100644
--- a/src/doc/en/installation/meson.rst
+++ b/src/doc/en/installation/meson.rst
@@ -55,8 +55,9 @@ or run the tests with ``./sage -t``.
By using ``pip install --editable`` in the above steps, the Sage library
is installed in editable mode. This means that when you only edit source
files, there is no need to rebuild the library; it suffices to restart Sage.
- Note that this even works when you edit Cython files, so you no longer need
- to manually compile after editing Cython files.
+ Note that this even works when you edit Cython files (they will be recompiled
+ automatically), so you no longer need to manually compile after editing Cython
+ files.
.. NOTE::
@@ -64,6 +65,15 @@ or run the tests with ``./sage -t``.
This means that any Sage-the-distribution commands such as ``sage -i``
will not work.
+.. NOTE::
+
+ By default, Meson will automatically determine the number of jobs to
+ run in parallel based on the number of CPU available. This can be adjusted
+ by passing ``--config-settings=compile-args=-jN`` to ``pip install``.
+
+ ``--verbose`` can be passed to ``pip install``, then the meson commands
+ internally used by pip will be printed out.
+
Background information
======================
@@ -78,6 +88,12 @@ To configure the project, we need to run the following command:
This will create a build directory ``builddir`` that will hold the build artifacts.
The ``--prefix`` option specifies the directory where the Sage will be installed.
+
+If pip is used as above, ``builddir`` is set to be
+``build/cp[Python major version][Python minor version]``, such as ``build/cp311``.
+``--prefix=`` can be left unspecified, when conda is used then meson will
+install to the conda environment e.g. ``$HOME/miniforge3/envs/sage-dev/``.
+
To compile the project, run the following command:
.. CODE-BLOCK:: shell-session
@@ -98,6 +114,8 @@ Usually, this directory is not on your Python path, so you have to use:
$ PYTHONPATH=build-install/lib/python3.11/site-packages ./sage
+When editable install is used, it is not necessary to reinstall after each compilation.
+
Alternatively, we can still use pip to install:
.. CODE-BLOCK:: shell-session
@@ -119,3 +137,17 @@ Alternatively, we can still use pip to install:
See `Meson's quick guide `_
and `Meson's install guide `_
for more information.
+
+Miscellaneous tips
+==================
+
+The environment variable ``MESONPY_EDITABLE_VERBOSE=1`` can be set while running ``./sage``,
+so that when Cython files are recompiled a message is printed out.
+
+If a new ``.pyx`` file is added, it need to be added to ``meson.build`` file in the
+containing directory.
+
+Unlike the ``make``-based build system which relies on header comments ``# distutils: language = c++``
+to determine whether C++ should be used, Meson-based build system requires specifying
+``override_options: ['cython_language=cpp']`` in the ``meson.build`` file.
+Similarly, dependencies need to be specified by ``dependencies: [...]``.
diff --git a/src/doc/en/reference/data_structures/index.rst b/src/doc/en/reference/data_structures/index.rst
index 08c03313ad3..1832d01eb75 100644
--- a/src/doc/en/reference/data_structures/index.rst
+++ b/src/doc/en/reference/data_structures/index.rst
@@ -9,5 +9,6 @@ Data Structures
sage/data_structures/bounded_integer_sequences
sage/data_structures/stream
sage/data_structures/mutable_poset
+ sage/data_structures/pairing_heap
.. include:: ../footer.txt
diff --git a/src/doc/en/reference/references/index.rst b/src/doc/en/reference/references/index.rst
index 3ebb8fbe2f1..ca81cda3f75 100644
--- a/src/doc/en/reference/references/index.rst
+++ b/src/doc/en/reference/references/index.rst
@@ -44,8 +44,8 @@ REFERENCES:
1995
.. [Ab2022] Willie Aboumrad,
- *Quantum compution with anyons: an F-matrix and braid calculator*
- (2022). https://arxiv.org/abs/2212.00831
+ *Quantum computing with anyons: an F-matrix and braid calculator*
+ (2022). :arxiv:`2212.00831`
.. [Alekseyev2006] \M. Alekseyev:
(Forum post on counting irreducible multivariate polynomials),
@@ -76,7 +76,7 @@ REFERENCES:
"Lilliput-AE: a New Lightweight Tweakable BlockCipher for Authenticated Encryption with AssociatedData"
https://csrc.nist.gov/CSRC/media/Projects/Lightweight-Cryptography/documents/round-1/spec-doc/LILLIPUT-AE-spec.pdf
-.. [ABCMT2019] \V. Arul, A. J. Best, E. Costa, R. Magner, and N. Triantafillou, *Computing zeta functions of cyclic covers in large characteristic,* The Open Book Series, vol. 2, no. 1, pp. 37–53, Jan. 2019.
+.. [ABCMT2019] \V. Arul, A. J. Best, E. Costa, R. Magner, and N. Triantafillou, *Computing zeta functions of cyclic covers in large characteristic*, The Open Book Series, vol. 2, no. 1, pp. 37–53, Jan. 2019.
.. [ABZ2007] \R. Aharoni and E. Berger and R. Ziv.
*Independent systems of representatives in weighted graphs*.
@@ -242,8 +242,8 @@ REFERENCES:
.. [AM1990] \R. Abraham and J. E. Marsden, "Foundations of Mechanics",
Addison-Wesley, 1980.
-.. [AM1974] \J. F. Adams and H. R. Margolis, "Sub-Hopf-algebras of the
- Steenrod algebra," Proc. Cambridge Philos. Soc. 76 (1974),
+.. [AM1974] \J. F. Adams and H. R. Margolis, *Sub-Hopf-algebras of the
+ Steenrod algebra*, Proc. Cambridge Philos. Soc. 76 (1974),
45-52.
.. [AM2000] \S. Ariki and A. Mathas.
@@ -444,16 +444,16 @@ REFERENCES:
Proc. Calgary Internat. Conference 1969, New York, 1970,
Gordon and Breach.
-.. [Bar2006] \G. Bard. 'Accelerating Cryptanalysis with the Method of
- Four Russians'. Cryptography E-Print Archive
+.. [Bar2006] \G. Bard. *Accelerating Cryptanalysis with the Method of
+ Four Russians*. Cryptography E-Print Archive
(http://eprint.iacr.org/2006/251.pdf), 2006.
.. [Bat1991] \V. V. Batyrev, *On the classification of smooth projective
toric varieties*, Tohoku Math. J. **43** (1991), 569-585
.. [Bat1994] Victor V. Batyrev,
- "Dual polyhedra and mirror symmetry for Calabi-Yau
- hypersurfaces in toric varieties",
+ *Dual polyhedra and mirror symmetry for Calabi-Yau
+ hypersurfaces in toric varieties*,
J. Algebraic Geom. 3 (1994), no. 3, 493-535.
:arxiv:`alg-geom/9310003v1`
@@ -540,14 +540,14 @@ REFERENCES:
.. [Bodin2007] \A. Bodin:
Number of irreducible polynomials in several variables over finite fields,
The American Mathematical Monthly 115(7), pp. 653-660, 2008.
- https://arxiv.org/abs/0706.0157
+ :arxiv:`0706.0157`
.. [BH2012] \A. Brouwer and W. Haemers,
Spectra of graphs,
Springer, 2012,
http://homepages.cwi.nl/~aeb/math/ipm/ipm.pdf
-.. [BMFPR2011] \M. Bousquet-Melou, É. Fusy, L.-F. Préville-Ratelle,
+.. [BMFPR2011] \M. Bousquet-Mélou, É. Fusy, L.-F. Préville-Ratelle,
*The number of intervals in the m-Tamari lattices*.
Electronic Journal of Combinatorics 18(2), 2011.
:doi:`10.37236/2027`
@@ -713,8 +713,8 @@ REFERENCES:
Journal of Algebraic Combinatorics (1992), vol.1, n.4, pp329-346,
:doi:`10.1023/A%3A1022438616684`.
-.. [Bec1992] Bernhard Beckermann. "A reliable method for computing M-Padé
- approximants on arbitrary staircases". J. Comput. Appl. Math.,
+.. [Bec1992] Bernhard Beckermann. *A reliable method for computing M-Padé
+ approximants on arbitrary staircases*. J. Comput. Appl. Math.,
40(1):19-42, 1992. :doi:`10.1016/0377-0427(92)90039-Z`.
.. [BeCoMe] Frits Beukers, Henri Cohen, Anton Mellit,
@@ -800,15 +800,16 @@ REFERENCES:
.. [BF2005] \R.L. Burden and J.D. Faires. *Numerical Analysis*.
8th edition, Thomson Brooks/Cole, 2005.
-.. [BFS2004] Magali Bardet, Jean-Charles Faugère, and Bruno Salvy, On
+.. [BFS2004] Magali Bardet, Jean-Charles Faugère, and Bruno Salvy, *On
the complexity of Groebner basis computation of
- semi-regular overdetermined algebraic equations.
+ semi-regular overdetermined algebraic equations.*
Proc. International Conference on Polynomial System
Solving (ICPSS), pp. 71-75, 2004.
.. [BFSS2006] \A. Bostan, P. Flajolet, B. Salvy and E. Schost, *Fast
Computation of special resultants*, Journal of Symbolic
Computation 41 (2006), 1-29
+ :doi:`10.1016/j.jsc.2005.07.001`
.. [BFZ2005] \A. Berenstein, \S. Fomin, and \A. Zelevinsky, *Cluster
algebras. III. Upper bounds and double Bruhat cells*,
@@ -1115,18 +1116,18 @@ REFERENCES:
lacunas of the Thue-Morse word*, Proc. GASCOM 2008 (June
16-20 2008, Bibbiena, Arezzo-Italia), 53--67.
-.. [BMFPR] \M. Bousquet-Melou, E. Fusy, L.-F. Preville Ratelle.
+.. [BMFPR] \M. Bousquet-Mélou, E. Fusy, L.-F. Preville Ratelle.
*The number of intervals in the m-Tamari lattices*. :arxiv:`1106.1498`
-.. [BMS2006] Bugeaud, Mignotte, and Siksek. "Classical and modular
+.. [BMS2006] Bugeaud, Mignotte, and Siksek. *Classical and modular
approaches to exponential Diophantine
- equations: I. Fibonacci and Lucas perfect powers." Annals
+ equations: I. Fibonacci and Lucas perfect powers.* Annals
of Math, 2006.
.. [BMSS2006] Alin Bostan, Bruno Salvy, François Morain, Éric Schost.
- Fast algorithms for computing isogenies between elliptic
- curves. [Research Report] 2006, pp.28.
- https://arxiv.org/pdf/cs/0609020.pdf
+ *Fast algorithms for computing isogenies between elliptic
+ curves*. [Research Report] 2006, pp.28.
+ :arxiv:`cs/0609020`
.. [BN2010] \D. Bump and M. Nakasuji.
Integration on `p`-adic groups and crystal bases.
@@ -1595,12 +1596,13 @@ REFERENCES:
IV. The quotient groups of the lower central series, Ann. of Math.
68 (1958) 81--95.
-.. [CFZ2000] \J. Cassaigne, S. Ferenczi, L.Q. Zamboni, Imbalances in
- Arnoux-Rauzy sequences, Ann. Inst. Fourier (Grenoble)
+.. [CFZ2000] \J. Cassaigne, S. Ferenczi, L.Q. Zamboni, *Imbalances in
+ Arnoux-Rauzy sequences*, Ann. Inst. Fourier (Grenoble)
50 (2000) 1265--1276.
-.. [CFZ2002] Chapoton, Fomin, Zelevinsky - Polytopal realizations of
- generalized associahedra, :arxiv:`math/0202004`.
+.. [CFZ2002] \F. Chapoton, S. Fomin, A. Zelevinsky - *Polytopal realizations of
+ generalized associahedra*, :arxiv:`math/0202004`,
+ :doi:`10.4153/CMB-2002-054-1`
.. [CGHLM2013] \P. Crescenzi, R. Grossi, M. Habib, L. Lanzi, A. Marino.
*On computing the diameter of real-world undirected graphs*.
@@ -1648,9 +1650,9 @@ REFERENCES:
.. [Cha18] Frédéric Chapoton, *Some properties of a new partial
order on Dyck paths*, 2018, :arxiv:`1809.10981`
-.. [Cha22005] \B. Cha. Vanishing of some cohomology groups and bounds
+.. [Cha22005] \B. Cha. *Vanishing of some cohomology groups and bounds
for the Shafarevich-Tate groups of elliptic
- curves. J. Number Theory, 111:154-178, 2005.
+ curves*. J. Number Theory, 111:154-178, 2005.
.. [Cha2008] Frédéric Chapoton.
*Sur le nombre d'intervalles dans les treillis de Tamari*.
@@ -1790,13 +1792,13 @@ REFERENCES:
:doi:`10.1007/978-3-319-07959-2_5`,
https://hal.inria.fr/hal-00943549/document
-.. [CMO2011] \C. Chun, D. Mayhew, J. Oxley, A chain theorem for
- internally 4-connected binary matroids. J. Combin. Theory
+.. [CMO2011] \C. Chun, D. Mayhew, J. Oxley, *A chain theorem for
+ internally 4-connected binary matroids*. J. Combin. Theory
Ser. B 101 (2011), 141-189.
-.. [CMO2012] \C. Chun, D. Mayhew, J. Oxley, Towards a splitter
+.. [CMO2012] \C. Chun, D. Mayhew, J. Oxley, *Towards a splitter
theorem for internally 4-connected binary
- matroids. J. Combin. Theory Ser. B 102 (2012), 688-700.
+ matroids*. J. Combin. Theory Ser. B 102 (2012), 688-700.
.. [CMR2005] C\. Cid, S\. Murphy, M\. Robshaw, *Small Scale Variants of
the AES*; in Proceedings of Fast Software Encryption
@@ -2773,6 +2775,11 @@ REFERENCES:
Cambridge University Press, Cambridge, 2009.
See also the `Errata list `_.
+.. [FSST1986] Michael L. Fredman, Robert Sedgewick, Daniel D. Sleator,
+ and Robert E. Tarjan. *The pairing heap: A new form of
+ self-adjusting heap*, Algorithmica, 1:111-129, 1986.
+ :doi:`10.1007/BF01840439`
+
.. [FST2012] \A. Felikson, \M. Shapiro, and \P. Tumarkin, *Cluster Algebras of
Finite Mutation Type Via Unfoldings*, Int Math Res Notices (2012)
2012 (8): 1768-1804.
diff --git a/src/sage/algebras/finite_dimensional_algebras/meson.build b/src/sage/algebras/finite_dimensional_algebras/meson.build
index 075f0b8cebd..85f04b2afcb 100644
--- a/src/sage/algebras/finite_dimensional_algebras/meson.build
+++ b/src/sage/algebras/finite_dimensional_algebras/meson.build
@@ -1,4 +1,5 @@
py.install_sources(
+ '__init__.py',
'all.py',
'finite_dimensional_algebra.py',
'finite_dimensional_algebra_element.pxd',
diff --git a/src/sage/algebras/fusion_rings/meson.build b/src/sage/algebras/fusion_rings/meson.build
index 281460a066a..221cce6146e 100644
--- a/src/sage/algebras/fusion_rings/meson.build
+++ b/src/sage/algebras/fusion_rings/meson.build
@@ -1,4 +1,5 @@
py.install_sources(
+ '__init__.py',
'all.py',
'f_matrix.py',
'fast_parallel_fmats_methods.pxd',
diff --git a/src/sage/algebras/letterplace/meson.build b/src/sage/algebras/letterplace/meson.build
index 1ada90927a7..3e429eb420a 100644
--- a/src/sage/algebras/letterplace/meson.build
+++ b/src/sage/algebras/letterplace/meson.build
@@ -1,4 +1,5 @@
py.install_sources(
+ '__init__.py',
'all.py',
'free_algebra_element_letterplace.pxd',
'free_algebra_letterplace.pxd',
diff --git a/src/sage/algebras/lie_algebras/meson.build b/src/sage/algebras/lie_algebras/meson.build
index f50959cb44b..754d8729fbb 100644
--- a/src/sage/algebras/lie_algebras/meson.build
+++ b/src/sage/algebras/lie_algebras/meson.build
@@ -1,4 +1,5 @@
py.install_sources(
+ '__init__.py',
'abelian.py',
'affine_lie_algebra.py',
'all.py',
diff --git a/src/sage/algebras/meson.build b/src/sage/algebras/meson.build
index a7e74474c6b..d3483851743 100644
--- a/src/sage/algebras/meson.build
+++ b/src/sage/algebras/meson.build
@@ -1,4 +1,5 @@
py.install_sources(
+ '__init__.py',
'affine_nil_temperley_lieb.py',
'algebra.py',
'all.py',
diff --git a/src/sage/algebras/quatalg/meson.build b/src/sage/algebras/quatalg/meson.build
index 2ec5cd31f22..25c4adfc46c 100644
--- a/src/sage/algebras/quatalg/meson.build
+++ b/src/sage/algebras/quatalg/meson.build
@@ -1,4 +1,5 @@
py.install_sources(
+ '__init__.py',
'all.py',
'quaternion_algebra.py',
'quaternion_algebra_element.pxd',
diff --git a/src/sage/algebras/weyl_algebra.py b/src/sage/algebras/weyl_algebra.py
index 8eae4797c7d..dc7cbef3058 100644
--- a/src/sage/algebras/weyl_algebra.py
+++ b/src/sage/algebras/weyl_algebra.py
@@ -29,7 +29,7 @@
from sage.categories.algebras_with_basis import AlgebrasWithBasis
from sage.sets.family import Family
import sage.data_structures.blas_dict as blas
-from sage.rings.polynomial.polynomial_ring import PolynomialRing_general
+from sage.rings.polynomial.polynomial_ring import PolynomialRing_generic
from sage.rings.polynomial.multi_polynomial_ring_base import MPolynomialRing_base
from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing
from sage.structure.global_options import GlobalOptions
@@ -677,7 +677,7 @@ def __classcall__(cls, R, names=None):
sage: W1 is W2
True
"""
- if isinstance(R, (PolynomialRing_general, MPolynomialRing_base)):
+ if isinstance(R, (PolynomialRing_generic, MPolynomialRing_base)):
if names is None:
names = R.variable_names()
R = R.base_ring()
diff --git a/src/sage/arith/meson.build b/src/sage/arith/meson.build
index 3c3656c5738..500b49edf85 100644
--- a/src/sage/arith/meson.build
+++ b/src/sage/arith/meson.build
@@ -1,4 +1,5 @@
py.install_sources(
+ '__init__.py',
'all.py',
'all__sagemath_objects.py',
'constants.pxd',
diff --git a/src/sage/calculus/meson.build b/src/sage/calculus/meson.build
index 541d7d86d75..3bedeb2220a 100644
--- a/src/sage/calculus/meson.build
+++ b/src/sage/calculus/meson.build
@@ -1,4 +1,5 @@
py.install_sources(
+ '__init__.py',
'all.py',
'calculus.py',
'desolvers.py',
diff --git a/src/sage/calculus/transforms/meson.build b/src/sage/calculus/transforms/meson.build
index 05d3fb59637..11ffa9f8ec1 100644
--- a/src/sage/calculus/transforms/meson.build
+++ b/src/sage/calculus/transforms/meson.build
@@ -1,4 +1,5 @@
py.install_sources(
+ '__init__.py',
'all.py',
'dft.py',
'dwt.pxd',
diff --git a/src/sage/categories/category_with_axiom.py b/src/sage/categories/category_with_axiom.py
index 014ac68d369..5e5b7ec8aff 100644
--- a/src/sage/categories/category_with_axiom.py
+++ b/src/sage/categories/category_with_axiom.py
@@ -2525,7 +2525,7 @@ def __init__(self, base_category):
Category_over_base_ring.__init__(self, base_category.base_ring())
-class CategoryWithAxiom_singleton(Category_singleton, CategoryWithAxiom):#, Category_singleton, FastHashable_class):
+class CategoryWithAxiom_singleton(Category_singleton, CategoryWithAxiom): # Category_singleton, FastHashable_class):
pass
diff --git a/src/sage/categories/drinfeld_modules.py b/src/sage/categories/drinfeld_modules.py
index aca5675497a..1e9bd910c70 100644
--- a/src/sage/categories/drinfeld_modules.py
+++ b/src/sage/categories/drinfeld_modules.py
@@ -29,7 +29,7 @@
from sage.rings.integer import Integer
lazy_import('sage.rings.polynomial.ore_polynomial_ring', 'OrePolynomialRing')
-lazy_import('sage.rings.polynomial.polynomial_ring', 'PolynomialRing_general')
+lazy_import('sage.rings.polynomial.polynomial_ring', 'PolynomialRing_generic')
lazy_import('sage.rings.ring_extension', 'RingExtension_generic')
@@ -251,7 +251,7 @@ def __init__(self, base_field, name='t'):
self._function_ring = base_morphism.domain()
# Check domain of base morphism is Fq[T]
function_ring = self._function_ring
- if not isinstance(function_ring, PolynomialRing_general):
+ if not isinstance(function_ring, PolynomialRing_generic):
raise NotImplementedError('function ring must be a polynomial '
'ring')
function_ring_base = function_ring.base_ring()
diff --git a/src/sage/categories/examples/meson.build b/src/sage/categories/examples/meson.build
index ecb63c913ba..bf5926b1d84 100644
--- a/src/sage/categories/examples/meson.build
+++ b/src/sage/categories/examples/meson.build
@@ -1,4 +1,5 @@
py.install_sources(
+ '__init__.py',
'algebras_with_basis.py',
'all.py',
'commutative_additive_monoids.py',
diff --git a/src/sage/categories/groupoid.py b/src/sage/categories/groupoid.py
index b197c092be5..4833b4e6f57 100644
--- a/src/sage/categories/groupoid.py
+++ b/src/sage/categories/groupoid.py
@@ -40,7 +40,7 @@ def __init__(self, G=None):
sage: C = Groupoid(S8)
sage: TestSuite(C).run()
"""
- CategoryWithParameters.__init__(self) #, "Groupoid")
+ CategoryWithParameters.__init__(self) # "Groupoid")
if G is None:
from sage.groups.perm_gps.permgroup_named import SymmetricGroup
G = SymmetricGroup(8)
@@ -56,8 +56,8 @@ def _repr_(self):
"""
return "Groupoid with underlying set %s" % self.__G
- #def construction(self):
- # return (self.__class__, self.__G)
+ # def construction(self):
+ # return (self.__class__, self.__G)
def _make_named_class_key(self, name):
"""
diff --git a/src/sage/categories/meson.build b/src/sage/categories/meson.build
index 132037fe7fd..affc2034df2 100644
--- a/src/sage/categories/meson.build
+++ b/src/sage/categories/meson.build
@@ -1,4 +1,5 @@
py.install_sources(
+ '__init__.py',
'action.pxd',
'additive_groups.py',
'additive_magmas.py',
diff --git a/src/sage/categories/unital_algebras.py b/src/sage/categories/unital_algebras.py
index b5c0dd73e86..33c10cf2c4a 100644
--- a/src/sage/categories/unital_algebras.py
+++ b/src/sage/categories/unital_algebras.py
@@ -319,7 +319,7 @@ def one_from_one_basis(self):
sage: Aone().parent() is A # needs sage.combinat sage.modules
True
"""
- return self.monomial(self.one_basis()) #.
+ return self.monomial(self.one_basis())
@lazy_attribute
def one(self):
diff --git a/src/sage/coding/codecan/meson.build b/src/sage/coding/codecan/meson.build
index 8749207de4b..1ccaca09b2a 100644
--- a/src/sage/coding/codecan/meson.build
+++ b/src/sage/coding/codecan/meson.build
@@ -1,4 +1,9 @@
-py.install_sources('all.py', 'codecan.pxd', subdir: 'sage/coding/codecan')
+py.install_sources(
+ '__init__.py',
+ 'all.py',
+ 'codecan.pxd',
+ subdir: 'sage/coding/codecan',
+)
extension_data = {
'autgroup_can_label' : files('autgroup_can_label.pyx'),
diff --git a/src/sage/coding/guruswami_sudan/interpolation.py b/src/sage/coding/guruswami_sudan/interpolation.py
index b1334307e79..3adc0ef1130 100644
--- a/src/sage/coding/guruswami_sudan/interpolation.py
+++ b/src/sage/coding/guruswami_sudan/interpolation.py
@@ -24,7 +24,7 @@
from sage.matrix.constructor import matrix
from sage.misc.misc_c import prod
-####################### Linear algebra system solving ###############################
+# ###################### Linear algebra system solving ###############################
def _flatten_once(lstlst):
@@ -50,9 +50,9 @@ def _flatten_once(lstlst):
for lst in lstlst:
yield from lst
-#*************************************************************
+# *************************************************************
# Linear algebraic Interpolation algorithm, helper functions
-#*************************************************************
+# *************************************************************
def _monomial_list(maxdeg, l, wy):
@@ -137,9 +137,9 @@ def eqs_affine(x0, y0):
jhat = monomial[1]
if ihat >= i and jhat >= j:
icoeff = binomial(ihat, i) * x0**(ihat-i) \
- if ihat > i else 1
+ if ihat > i else 1
jcoeff = binomial(jhat, j) * y0**(jhat-j) \
- if jhat > j else 1
+ if jhat > j else 1
eq[monomial] = jcoeff * icoeff
eqs.append([eq.get(monomial, 0) for monomial in monomials])
return eqs
@@ -284,12 +284,12 @@ def gs_interpolation_linalg(points, tau, parameters, wy):
# Pick a nonzero element from the right kernel
sol = Ker.basis()[0]
# Construct the Q polynomial
- PF = M.base_ring()['x', 'y'] #make that ring a ring in
+ PF = M.base_ring()['x', 'y'] # make that ring a ring in
x, y = PF.gens()
- Q = sum([x**monomials[i][0] * y**monomials[i][1] * sol[i] for i in range(0, len(monomials))])
- return Q
+ return sum([x**m[0] * y**m[1] * sol[i]
+ for i, m in enumerate(monomials)])
-####################### Lee-O'Sullivan's method ###############################
+# ###################### Lee-O'Sullivan's method ###############################
def lee_osullivan_module(points, parameters, wy):
@@ -397,12 +397,11 @@ def gs_interpolation_lee_osullivan(points, tau, parameters, wy):
from .utils import _degree_of_vector
s, l = parameters[0], parameters[1]
F = points[0][0].parent()
- M = lee_osullivan_module(points, (s,l), wy)
- shifts = [i * wy for i in range(0,l+1)]
+ M = lee_osullivan_module(points, (s, l), wy)
+ shifts = [i * wy for i in range(l + 1)]
Mnew = M.reduced_form(shifts=shifts)
# Construct Q as the element of the row with the lowest weighted degree
Qlist = min(Mnew.rows(), key=lambda r: _degree_of_vector(r, shifts))
PFxy = F['x,y']
xx, yy = PFxy.gens()
- Q = sum(yy**i * PFxy(Qlist[i]) for i in range(0,l+1))
- return Q
+ return sum(yy**i * PFxy(Qlist[i]) for i in range(l + 1))
diff --git a/src/sage/coding/linear_code_no_metric.py b/src/sage/coding/linear_code_no_metric.py
index 49c30a415c8..b9ad941ed09 100644
--- a/src/sage/coding/linear_code_no_metric.py
+++ b/src/sage/coding/linear_code_no_metric.py
@@ -191,7 +191,7 @@ def __init__(self, base_field, length, default_encoder_name, default_decoder_nam
super().__init__(length, default_encoder_name, default_decoder_name, metric)
cat = Modules(base_field).FiniteDimensional().WithBasis().Finite()
facade_for = VectorSpace(base_field, self._length)
- self.Element = type(facade_for.an_element()) # for when we made this a non-facade parent
+ self.Element = facade_for.Element
Parent.__init__(self, base=base_field, facade=facade_for, category=cat)
def base_field(self):
diff --git a/src/sage/coding/meson.build b/src/sage/coding/meson.build
index 65b2e0d8eb1..b311c8df5d5 100644
--- a/src/sage/coding/meson.build
+++ b/src/sage/coding/meson.build
@@ -1,4 +1,5 @@
py.install_sources(
+ '__init__.py',
'abstract_code.py',
'ag_code.py',
'all.py',
diff --git a/src/sage/coding/reed_muller_code.py b/src/sage/coding/reed_muller_code.py
index e690534c5e3..4f7759440ab 100644
--- a/src/sage/coding/reed_muller_code.py
+++ b/src/sage/coding/reed_muller_code.py
@@ -396,11 +396,22 @@ class directly, as :meth:`ReedMullerCode` creates either a binary or a
EXAMPLES:
- A binary Reed-Muller code can be constructed by simply giving the order of the code and the number of variables::
+ A binary Reed-Muller code can be constructed by simply giving the order of
+ the code and the number of variables::
sage: C = codes.BinaryReedMullerCode(2, 4)
sage: C
Binary Reed-Muller Code of order 2 and number of variables 4
+
+ Very large Reed-Muller codes can be constructed without building
+ the generator matrix or elements of the code (fixes :issue:`33229`,
+ see also :issue:`39110`)::
+
+ sage: C = codes.BinaryReedMullerCode(16, 32)
+ sage: C
+ Binary Reed-Muller Code of order 16 and number of variables 32
+ sage: C.dimension(), C.length()
+ (2448023843, 4294967296)
"""
_registered_encoders = {}
diff --git a/src/sage/combinat/crystals/meson.build b/src/sage/combinat/crystals/meson.build
index 96ff9f4e19e..5c6b864d04a 100644
--- a/src/sage/combinat/crystals/meson.build
+++ b/src/sage/combinat/crystals/meson.build
@@ -1,4 +1,5 @@
py.install_sources(
+ '__init__.py',
'affine.py',
'affine_factorization.py',
'affinization.py',
diff --git a/src/sage/combinat/designs/meson.build b/src/sage/combinat/designs/meson.build
index fd3a8896bb3..019b62be54e 100644
--- a/src/sage/combinat/designs/meson.build
+++ b/src/sage/combinat/designs/meson.build
@@ -1,5 +1,6 @@
py.install_sources(
'MOLS_handbook_data.py',
+ '__init__.py',
'all.py',
'bibd.py',
'block_design.py',
diff --git a/src/sage/combinat/diagram_algebras.py b/src/sage/combinat/diagram_algebras.py
index 6410a4a93ea..b929327a28e 100644
--- a/src/sage/combinat/diagram_algebras.py
+++ b/src/sage/combinat/diagram_algebras.py
@@ -129,14 +129,14 @@ def brauer_diagrams(k):
{{-3, 3}, {-2, 2}, {-1, 1}}]
"""
if k in ZZ:
- s = list(range(1,k+1)) + list(range(-k,0))
+ s = list(range(1, k+1)) + list(range(-k,0))
for p in perfect_matchings_iterator(k):
yield [(s[a],s[b]) for a,b in p]
- elif k + ZZ(1) / ZZ(2) in ZZ: # Else k in 1/2 ZZ
- k = ZZ(k + ZZ(1) / ZZ(2))
+ elif k + ZZ.one() / 2 in ZZ: # Else k in 1/2 ZZ
+ k = ZZ(k + ZZ.one() / 2)
s = list(range(1, k)) + list(range(-k+1,0))
for p in perfect_matchings_iterator(k-1):
- yield [(s[a],s[b]) for a,b in p] + [[k, -k]]
+ yield [(s[a], s[b]) for a, b in p] + [[k, -k]]
def temperley_lieb_diagrams(k):
@@ -1203,7 +1203,7 @@ def __init__(self, order, category=None):
self.order = ZZ(order)
base_set = frozenset(list(range(1,order+1)) + list(range(-order,0)))
else:
- #order is a half-integer.
+ # order is a half-integer.
self.order = QQ(order)
base_set = frozenset(list(range(1,ZZ(ZZ(1)/ZZ(2) + order)+1))
+ list(range(ZZ(-ZZ(1)/ZZ(2) - order),0)))
@@ -4865,7 +4865,7 @@ def key_func(P):
count_left += 1
for j in range(i):
prop_intervals[j].append([bot])
- for j in range(i+1,total_prop):
+ for j in range(i+1, total_prop):
prop_intervals[j].append([top])
if not left_moving:
top, bot = bot, top
@@ -4964,10 +4964,10 @@ def sgn(x):
for i in list(diagram):
l1.append(list(i))
l2.extend(list(i))
- output = "\\begin{tikzpicture}[scale = 0.5,thick, baseline={(0,-1ex/2)}] \n\\tikzstyle{vertex} = [shape = circle, minimum size = 7pt, inner sep = 1pt] \n" #setup beginning of picture
- for i in l2: #add nodes
+ output = "\\begin{tikzpicture}[scale = 0.5,thick, baseline={(0,-1ex/2)}] \n\\tikzstyle{vertex} = [shape = circle, minimum size = 7pt, inner sep = 1pt] \n" # setup beginning of picture
+ for i in l2: # add nodes
output = output + "\\node[vertex] (G-{}) at ({}, {}) [shape = circle, draw{}] {{}}; \n".format(i, (abs(i)-1)*1.5, sgn(i), filled_str)
- for i in l1: #add edges
+ for i in l1: # add edges
if len(i) > 1:
l4 = list(i)
posList = []
@@ -4980,21 +4980,21 @@ def sgn(x):
posList.sort()
negList.sort()
l4 = posList + negList
- l5 = l4[:] #deep copy
+ l5 = l4[:] # deep copy
for j in range(len(l5)):
- l5[j-1] = l4[j] #create a permuted list
+ l5[j-1] = l4[j] # create a permuted list
if len(l4) == 2:
l4.pop()
- l5.pop() #pops to prevent duplicating edges
+ l5.pop() # pops to prevent duplicating edges
for j in zip(l4, l5):
xdiff = abs(j[1])-abs(j[0])
y1 = sgn(j[0])
y2 = sgn(j[1])
- if y2-y1 == 0 and abs(xdiff) < 5: #if nodes are close to each other on same row
- diffCo = (0.5+0.1*(abs(xdiff)-1)) #gets bigger as nodes are farther apart; max value of 1; min value of 0.5.
+ if y2-y1 == 0 and abs(xdiff) < 5: # if nodes are close to each other on same row
+ diffCo = (0.5+0.1*(abs(xdiff)-1)) # gets bigger as nodes are farther apart; max value of 1; min value of 0.5.
outVec = (sgn(xdiff)*diffCo, -1*diffCo*y1)
inVec = (-1*diffCo*sgn(xdiff), -1*diffCo*y2)
- elif y2-y1 != 0 and abs(xdiff) == 1: #if nodes are close enough curviness looks bad.
+ elif y2-y1 != 0 and abs(xdiff) == 1: # if nodes are close enough curviness looks bad.
outVec = (sgn(xdiff)*0.75, -1*y1)
inVec = (-1*sgn(xdiff)*0.75, -1*y2)
else:
@@ -5002,7 +5002,7 @@ def sgn(x):
inVec = (-1*sgn(xdiff), -1*y2)
output = output + "\\draw[{}] (G-{}) .. controls +{} and +{} .. {}(G-{}); \n".format(
edge_options(j), j[0], outVec, inVec, edge_additions(j), j[1])
- output = output + "\\end{tikzpicture}" #end picture
+ output = output + "\\end{tikzpicture}" # end picture
return output
diff --git a/src/sage/combinat/growth.py b/src/sage/combinat/growth.py
index 958b664e7cd..542d4dfb280 100644
--- a/src/sage/combinat/growth.py
+++ b/src/sage/combinat/growth.py
@@ -2592,11 +2592,11 @@ def forward_rule(self, y, e, t, f, x, content):
z, h = x, e
elif x == t != y:
z, h = y, e
- else: # x != t and y != t
+ else: # x != t and y != t
qx = SkewPartition([x.to_partition(), t.to_partition()])
qy = SkewPartition([y.to_partition(), t.to_partition()])
if not all(c in qx.cells() for c in qy.cells()):
- res = [(j-i) % self.k for i,j in qx.cells()]
+ res = [(j-i) % self.k for i, j in qx.cells()]
assert len(set(res)) == 1
r = res[0]
z = y.affine_symmetric_group_simple_action(r)
diff --git a/src/sage/combinat/integer_lists/invlex.pyx b/src/sage/combinat/integer_lists/invlex.pyx
index 6bef85031ce..bfb4c8dc3d7 100644
--- a/src/sage/combinat/integer_lists/invlex.pyx
+++ b/src/sage/combinat/integer_lists/invlex.pyx
@@ -860,14 +860,18 @@ If you know what you are doing, you can set check=False to skip this warning."""
OUTPUT:
- ``None`` if this method finds a proof that there
+ ``True`` if this method finds a proof that there
exists an upper bound on the length. Otherwise a
:exc:`ValueError` is raised.
+ Note that :func:`cached_method` does not work with methods
+ returning ``None``, so ``True`` is returned instead.
+
EXAMPLES::
sage: L = IntegerListsLex(4, max_length=4)
sage: L._check_finiteness()
+ True
The following example is infinite::
@@ -1002,20 +1006,20 @@ If you know what you are doing, you can set check=False to skip this warning."""
"""
# Trivial cases
if self.max_length < Infinity:
- return
+ return True
if self.max_sum < self.min_sum:
- return
+ return True
if self.min_slope > self.max_slope:
- return
+ return True
if self.max_slope < 0:
- return
+ return True
if self.ceiling.limit() < self.floor.limit():
- return
+ return True
if self.ceiling.limit() == 0:
# This assumes no trailing zeroes
- return
+ return True
if self.min_slope > 0 and self.ceiling.limit() < Infinity:
- return
+ return True
# Compute a lower bound on the sum of floor(i) for i=1 to infinity
if self.floor.limit() > 0 or self.min_slope > 0:
@@ -1028,10 +1032,10 @@ If you know what you are doing, you can set check=False to skip this warning."""
floor_sum_lower_bound = Infinity
if self.max_sum < floor_sum_lower_bound:
- return
+ return True
if self.max_sum == floor_sum_lower_bound and self.max_sum < Infinity:
# This assumes no trailing zeroes
- return
+ return True
# Variant on ceiling.limit() ==0 where we actually discover that the ceiling limit is 0
if ( self.max_slope == 0 and
@@ -1039,13 +1043,13 @@ If you know what you are doing, you can set check=False to skip this warning."""
(self.ceiling.limit_start() < Infinity and
any(self.ceiling(i) == 0 for i in range(self.ceiling.limit_start()+1)))
) ):
- return
+ return True
limit_start = max(self.ceiling.limit_start(), self.floor.limit_start())
if limit_start < Infinity:
for i in range(limit_start+1):
if self.ceiling(i) < self.floor(i):
- return
+ return True
raise ValueError("could not prove that the specified constraints yield a finite set")
diff --git a/src/sage/combinat/k_tableau.py b/src/sage/combinat/k_tableau.py
index de6b783f15b..cb6d6fbc087 100644
--- a/src/sage/combinat/k_tableau.py
+++ b/src/sage/combinat/k_tableau.py
@@ -1625,12 +1625,12 @@ def from_core_tableau(cls, t, k):
[[None, 2], [3]]
"""
t = SkewTableau(list(t))
- shapes = [ Core(p, k+1).to_bounded_partition() for p in intermediate_shapes(t) ]#.to_chain() ]
+ shapes = [ Core(p, k+1).to_bounded_partition() for p in intermediate_shapes(t) ] # .to_chain() ]
if t.inner_shape() == Partition([]):
l = []
else:
l = [[None]*i for i in shapes[0]]
- for i in range(1,len(shapes)):
+ for i in range(1, len(shapes)):
p = shapes[i]
if len(l) < len(p):
l += [[]]
@@ -2068,8 +2068,10 @@ def from_core_tableau(cls, t, k):
[s0*s3, s2*s1]
"""
t = SkewTableau(list(t))
- shapes = [ Core(p, k+1).to_grassmannian() for p in intermediate_shapes(t) ] #t.to_chain() ]
- perms = [ shapes[i]*(shapes[i-1].inverse()) for i in range(len(shapes)-1,0,-1)]
+ shapes = [Core(p, k + 1).to_grassmannian()
+ for p in intermediate_shapes(t)] # t.to_chain() ]
+ perms = [shapes[i] * (shapes[i - 1].inverse())
+ for i in range(len(shapes) - 1, 0, -1)]
return cls(perms, k, inner_shape=t.inner_shape())
def k_charge(self, algorithm='I'):
@@ -4222,16 +4224,16 @@ def _left_action_list( cls, Tlist, tij, v, k ):
"""
innershape = Core([len(r) for r in Tlist], k + 1)
outershape = innershape.affine_symmetric_group_action(tij, transposition=True)
- if outershape.length() == innershape.length()+1:
+ if outershape.length() == innershape.length() + 1:
for c in SkewPartition([outershape.to_partition(),innershape.to_partition()]).cells():
while c[0] >= len(Tlist):
Tlist.append([])
- Tlist[c[0]].append( v )
+ Tlist[c[0]].append(v)
if len(Tlist[c[0]])-c[0] == tij[1]:
- Tlist[c[0]][-1] = -Tlist[c[0]][-1] #mark the cell that is on the j-1 diagonal
+ Tlist[c[0]][-1] = -Tlist[c[0]][-1] # mark the cell that is on the j-1 diagonal
return Tlist
- else:
- raise ValueError("%s is not a single step up in the strong lattice" % tij)
+
+ raise ValueError("%s is not a single step up in the strong lattice" % tij)
@classmethod
def follows_tableau_unsigned_standard( cls, Tlist, k ):
diff --git a/src/sage/combinat/matrices/meson.build b/src/sage/combinat/matrices/meson.build
index 86021f8d376..d316252bca0 100644
--- a/src/sage/combinat/matrices/meson.build
+++ b/src/sage/combinat/matrices/meson.build
@@ -1,4 +1,5 @@
py.install_sources(
+ '__init__.py',
'all.py',
'dlxcpp.py',
'hadamard_matrix.py',
diff --git a/src/sage/combinat/meson.build b/src/sage/combinat/meson.build
index 8c1aba5bd50..441caadca17 100644
--- a/src/sage/combinat/meson.build
+++ b/src/sage/combinat/meson.build
@@ -1,5 +1,6 @@
py.install_sources(
'SJT.py',
+ '__init__.py',
'abstract_tree.py',
'affine_permutation.py',
'algebraic_combinatorics.py',
diff --git a/src/sage/combinat/multiset_partition_into_sets_ordered.py b/src/sage/combinat/multiset_partition_into_sets_ordered.py
old mode 100755
new mode 100644
diff --git a/src/sage/combinat/partition_kleshchev.py b/src/sage/combinat/partition_kleshchev.py
index cfa78933e37..444a46f2cf1 100644
--- a/src/sage/combinat/partition_kleshchev.py
+++ b/src/sage/combinat/partition_kleshchev.py
@@ -162,9 +162,9 @@ def conormal_cells(self, i=None):
carry[res] += 1
else:
res = KP._multicharge[0] + self[row] - row - 1
- if row == len(self)-1 or self[row] > self[row+1]: # removable cell
+ if row == len(self)-1 or self[row] > self[row+1]: # removable cell
carry[res] -= 1
- if row == 0 or self[row-1] > self[row]: #addable cell
+ if row == 0 or self[row-1] > self[row]: # addable cell
if carry[res+1] >= 0:
conormals[res+1].append((row, self[row]))
else:
@@ -661,25 +661,25 @@ def normal_cells(self, i=None):
part_lens = [len(part) for part in self] # so we don't repeatedly call these
KP = self.parent()
if KP._convention[0] == 'L':
- rows = [(k,r) for k,ell in enumerate(part_lens) for r in range(ell+1)]
+ rows = [(k, r) for k, ell in enumerate(part_lens) for r in range(ell+1)]
else:
- rows = [(k,r) for k,ell in reversed(list(enumerate(part_lens))) for r in range(ell+1)]
+ rows = [(k, r) for k, ell in reversed(list(enumerate(part_lens))) for r in range(ell+1)]
if KP._convention[1] == 'S':
rows.reverse()
for row in rows:
- k,r = row
- if r == part_lens[k]: # addable cell at bottom of a component
+ k, r = row
+ if r == part_lens[k]: # addable cell at bottom of a component
carry[KP._multicharge[k]-r] += 1
else:
part = self[k]
res = KP._multicharge[k] + (part[r] - r - 1)
- if r == part_lens[k]-1 or part[r] > part[r+1]: # removable cell
+ if r == part_lens[k]-1 or part[r] > part[r+1]: # removable cell
if carry[res] == 0:
normals[res].insert(0, (k, r, part[r]-1))
else:
carry[res] -= 1
- if r == 0 or part[r-1] > part[r]: #addable cell
+ if r == 0 or part[r-1] > part[r]: # addable cell
carry[res+1] += 1
# finally return the result
diff --git a/src/sage/combinat/posets/meson.build b/src/sage/combinat/posets/meson.build
index 07837832519..9832967b4ff 100644
--- a/src/sage/combinat/posets/meson.build
+++ b/src/sage/combinat/posets/meson.build
@@ -1,4 +1,5 @@
py.install_sources(
+ '__init__.py',
'all.py',
'cartesian_product.py',
'd_complete.py',
diff --git a/src/sage/combinat/rigged_configurations/meson.build b/src/sage/combinat/rigged_configurations/meson.build
index 6b12159dfda..40d0f4e42c5 100644
--- a/src/sage/combinat/rigged_configurations/meson.build
+++ b/src/sage/combinat/rigged_configurations/meson.build
@@ -1,4 +1,5 @@
py.install_sources(
+ '__init__.py',
'all.py',
'bij_abstract_class.py',
'bij_infinity.py',
diff --git a/src/sage/combinat/root_system/cartan_type.py b/src/sage/combinat/root_system/cartan_type.py
index ce5762719e2..19c500a412f 100644
--- a/src/sage/combinat/root_system/cartan_type.py
+++ b/src/sage/combinat/root_system/cartan_type.py
@@ -841,7 +841,9 @@ def _samples(self):
[CartanType(t) for t in [["I", 5], ["H", 3], ["H", 4]]] + \
[t.affine() for t in finite_crystallographic if t.is_irreducible()] + \
[CartanType(t) for t in [["BC", 1, 2], ["BC", 5, 2]]] + \
- [CartanType(t).dual() for t in [["B", 5, 1], ["C", 4, 1], ["F", 4, 1], ["G", 2, 1],["BC", 1, 2], ["BC", 5, 2]]] #+ \
+ [CartanType(t).dual() for t in [["B", 5, 1], ["C", 4, 1],
+ ["F", 4, 1], ["G", 2, 1],
+ ["BC", 1, 2], ["BC", 5, 2]]] # + \
# [ g ]
_colors = {1: 'blue', -1: 'blue',
diff --git a/src/sage/combinat/root_system/meson.build b/src/sage/combinat/root_system/meson.build
index 35e7bfb1950..629c67bcdd6 100644
--- a/src/sage/combinat/root_system/meson.build
+++ b/src/sage/combinat/root_system/meson.build
@@ -1,4 +1,5 @@
py.install_sources(
+ '__init__.py',
'all.py',
'ambient_space.py',
'associahedron.py',
diff --git a/src/sage/combinat/sf/sfa.py b/src/sage/combinat/sf/sfa.py
index 92a068e4c8c..60fc4b65c53 100644
--- a/src/sage/combinat/sf/sfa.py
+++ b/src/sage/combinat/sf/sfa.py
@@ -2284,28 +2284,28 @@ def _invert_morphism(self, n, base_ring,
sage: c2 == d2
True
"""
- #Decide whether we know how to go from self to other or
- #from other to self
+ # Decide whether we know how to go from self to other or
+ # from other to self
if to_other_function is not None:
- known_cache = self_to_other_cache #the known direction
- unknown_cache = other_to_self_cache #the unknown direction
+ known_cache = self_to_other_cache # the known direction
+ unknown_cache = other_to_self_cache # the unknown direction
known_function = to_other_function
else:
- unknown_cache = self_to_other_cache #the known direction
- known_cache = other_to_self_cache #the unknown direction
+ unknown_cache = self_to_other_cache # the known direction
+ known_cache = other_to_self_cache # the unknown direction
known_function = to_self_function
- #Do nothing if we've already computed the inverse
- #for degree n.
+ # Do nothing if we've already computed the inverse
+ # for degree n.
if n in known_cache and n in unknown_cache:
return
- #Univariate polynomial arithmetic is faster
- #over ZZ. Since that is all we need to compute
- #the transition matrices between S and P, we
- #should use that.
- #Zt = ZZ['t']
- #t = Zt.gen()
+ # Univariate polynomial arithmetic is faster
+ # over ZZ. Since that is all we need to compute
+ # the transition matrices between S and P, we
+ # should use that.
+ # Zt = ZZ['t']
+ # t = Zt.gen()
one = base_ring.one()
zero = base_ring.zero()
diff --git a/src/sage/combinat/six_vertex_model.py b/src/sage/combinat/six_vertex_model.py
index 879418f18d9..ca70c9661c6 100644
--- a/src/sage/combinat/six_vertex_model.py
+++ b/src/sage/combinat/six_vertex_model.py
@@ -777,7 +777,7 @@ def to_alternating_sign_matrix(self):
[ 0 1 -1 1]
[ 0 0 1 0]
"""
- from sage.combinat.alternating_sign_matrix import AlternatingSignMatrix #AlternatingSignMatrices
- #ASM = AlternatingSignMatrices(self.parent()._nrows)
- #return ASM(self.to_signed_matrix())
+ from sage.combinat.alternating_sign_matrix import AlternatingSignMatrix # AlternatingSignMatrices
+ # ASM = AlternatingSignMatrices(self.parent()._nrows)
+ # return ASM(self.to_signed_matrix())
return AlternatingSignMatrix(self.to_signed_matrix())
diff --git a/src/sage/combinat/words/meson.build b/src/sage/combinat/words/meson.build
index bb12f65d28f..2333d8dc0cd 100644
--- a/src/sage/combinat/words/meson.build
+++ b/src/sage/combinat/words/meson.build
@@ -1,4 +1,5 @@
py.install_sources(
+ '__init__.py',
'abstract_word.py',
'all.py',
'alphabet.py',
diff --git a/src/sage/crypto/lattice.py b/src/sage/crypto/lattice.py
index 430ab98f3ae..32b4f1c8be2 100644
--- a/src/sage/crypto/lattice.py
+++ b/src/sage/crypto/lattice.py
@@ -22,7 +22,7 @@
# http://www.gnu.org/licenses/
#*****************************************************************************
-from sage.rings.polynomial.polynomial_ring import PolynomialRing_general
+from sage.rings.polynomial.polynomial_ring import PolynomialRing_generic
def gen_lattice(type='modular', n=4, m=8, q=11, seed=None,
@@ -253,7 +253,7 @@ def gen_lattice(type='modular', n=4, m=8, q=11, seed=None,
P = quotient.parent()
# P should be a univariate polynomial ring over ZZ_q
- if not isinstance(P, PolynomialRing_general):
+ if not isinstance(P, PolynomialRing_generic):
raise TypeError("quotient should be a univariate polynomial")
assert P.base_ring() is ZZ_q
diff --git a/src/sage/data_structures/meson.build b/src/sage/data_structures/meson.build
index 8a94548917b..8c100328378 100644
--- a/src/sage/data_structures/meson.build
+++ b/src/sage/data_structures/meson.build
@@ -1,4 +1,5 @@
py.install_sources(
+ '__init__.py',
'all.py',
'binary_matrix.pxd',
'binary_search.pxd',
@@ -9,6 +10,8 @@ py.install_sources(
'bounded_integer_sequences.pxd',
'list_of_pairs.pxd',
'mutable_poset.py',
+ 'pairing_heap.h',
+ 'pairing_heap.pxd',
'sparse_bitset.pxd',
'stream.py',
subdir: 'sage/data_structures',
@@ -39,3 +42,18 @@ foreach name, pyx : extension_data
)
endforeach
+extension_data_cpp = {
+ 'pairing_heap' : files('pairing_heap.pyx'),
+}
+
+foreach name, pyx : extension_data_cpp
+ py.extension_module(
+ name,
+ sources: pyx,
+ subdir: 'sage/data_structures/',
+ install: true,
+ override_options: ['cython_language=cpp'],
+ include_directories: [inc_cpython, inc_data_structures],
+ dependencies: [py_dep, cysignals, gmp],
+ )
+endforeach
diff --git a/src/sage/data_structures/pairing_heap.h b/src/sage/data_structures/pairing_heap.h
new file mode 100644
index 00000000000..3c6cbbf4216
--- /dev/null
+++ b/src/sage/data_structures/pairing_heap.h
@@ -0,0 +1,344 @@
+/*
+ * Pairing heap
+ *
+ * Implements a pairing heap data structure as described in [1]. See also [2]
+ * for more details.
+ *
+ * This implementation is templated by the type TI of items and the type TV of
+ * the value associated with an item. The type TI must be either a standard type
+ * (int, size_t, etc.) or a type equipped with a has function as supported by
+ * std::unordered_map. The top of the heap is the item with smallest value,
+ * i.e., this is a min heap data structure. The number of items in the heap is
+ * not fixed. It supports the following operations:
+ *
+ * - empty(): return true if the heap is empty, and false otherwise.
+ *
+ * - push(item, value): push an item to the heap with specified value.
+ *
+ * - top(): access the pair (item, value) at the top of the heap, i.e., with
+ * smallest value in time O(1).
+ * This operation assumes that the heap is not empty.
+ *
+ * - top_item(): access the item at the top of the heap in time O(1).
+ * This operation assumes that the heap is not empty.
+ *
+ * - top_value(): access the value of the item at the top of the heap in O(1).
+ * This operation assumes that the heap is not empty.
+ *
+ * - pop(): remove top item from the heap in amortize time O(log(n)).
+ *
+ * - decrease(item, new_value): change the value associated with the item to the
+ * specified value ``new_value`` in time o(log(n)). The new value must be
+ * smaller than the previous one. Otherwise the structure of the heap is no
+ * longer guaranteed.
+ * If the item is not already in the heap, this method calls method ``push``.
+ *
+ * - contains(item): check whether specified item is in the heap in time O(1).
+ *
+ * - value(item): return the value associated with the item in the heap.
+ * This operation assumes that the item is already in the heap.
+ *
+ * References:
+ *
+ * [1] M. L. Fredman, R. Sedgewick, D. D. Sleator, and R. E. Tarjan.
+ * "The pairing heap: a new form of self-adjusting heap".
+ * Algorithmica. 1 (1): 111-129, 1986. doi:10.1007/BF01840439.
+ *
+ * [2] https://en.wikipedia.org/wiki/Pairing_heap
+ *
+ * Author:
+ * - David Coudert
+ *
+ */
+
+#ifndef PAIRING_HEAP_H
+#define PAIRING_HEAP_H
+
+#include
+#include
+
+namespace pairing_heap {
+
+ template<
+ typename TV, // type of values
+ typename T // type of the child class
+ >
+ struct PairingHeapNodeBase {
+ public:
+
+ bool operator<=(PairingHeapNodeBase const& other) const {
+ return static_cast(this)->le_implem(static_cast(other));
+ }
+
+ // Pair list of heaps and return pointer to the top of resulting heap
+ static T *_pair(T *p) {
+ if (p == nullptr) {
+ return nullptr;
+ }
+
+ /*
+ * Move toward the end of the list, counting elements along the way.
+ * This is done in order to:
+ * - know whether the list has odd or even number of nodes
+ * - speed up going-back through the list
+ */
+ size_t children = 1;
+ T *it = p;
+ while (it->next != nullptr) {
+ it = it->next;
+ children++;
+ }
+
+ T *result;
+
+ if (children % 2 == 1) {
+ T *a = it;
+ it = it->prev;
+ a->prev = a->next = nullptr;
+ result = a;
+ } else {
+ T *a = it;
+ T *b = it->prev;
+ it = it->prev->prev;
+ a->prev = a->next = b->prev = b->next = nullptr;
+ result = _merge(a, b);
+ }
+
+ for (size_t i = 0; i < (children - 1) / 2; i++) {
+ T *a = it;
+ T *b = it->prev;
+ it = it->prev->prev;
+ a->prev = a->next = b->prev = b->next = nullptr;
+ result = _merge(_merge(a, b), result);
+ }
+
+ return result;
+ } // end _pair
+
+
+ // Merge 2 heaps and return pointer to the top of resulting heap
+ static T *_merge(T *a, T *b) {
+ if (*a <= *b) { // Use comparison method of PairingHeapNodeBase
+ _link(a, b);
+ return a;
+ } else {
+ _link(b, a);
+ return b;
+ }
+ } // end _merge
+
+
+ // Make b a child of a
+ static void _link(T *a, T *b) {
+ if (a->child != nullptr) {
+ b->next = a->child;
+ a->child->prev = b;
+ }
+ b->prev = a;
+ a->child = b;
+ } // end _link
+
+
+ // Remove p from its parent children list
+ static void _unlink(T *p) {
+ if (p->prev->child == p) {
+ p->prev->child = p->next;
+ } else {
+ p->prev->next = p->next;
+ }
+ if (p->next != nullptr) {
+ p->next->prev = p->prev;
+ }
+ p->prev = nullptr;
+ p->next = nullptr;
+ } // end _unlink
+
+
+ TV value; // value associated to the node
+ T * prev; // Previous sibling of the node or parent
+ T * next; // Next sibling of the node
+ T * child; // First child of the node
+
+ protected:
+ // Only derived class can build a PairingHeapNodeBase
+ explicit PairingHeapNodeBase(const TV &some_value)
+ : value{some_value}, prev{nullptr}, next{nullptr}, child{nullptr} {
+ }
+ }; // end struct PairingHeapNodeBase
+
+
+ template<
+ typename TI, // type of items stored in the node
+ typename TV // type of values associated with the stored item
+ // Assumes TV is a comparable type
+ >
+ class PairingHeapNode
+ : public PairingHeapNodeBase> {
+
+ public:
+ PairingHeapNode(TI const& some_item, TV const& some_value)
+ : Base_(some_value), item(some_item) {
+ }
+
+ bool le_implem(PairingHeapNode const& other) const {
+ return this->value <= other.value;
+ }
+
+ TI item; // item contained in the node
+
+ private:
+ using Base_ = PairingHeapNodeBase>;
+ };
+
+
+ class PairingHeapNodePy
+ : public PairingHeapNodeBase {
+ public:
+ PairingHeapNodePy(PyObject *some_value)
+ : Base_(some_value) {
+ }
+
+ bool le_implem(PairingHeapNodePy const& other) const {
+ return PyObject_RichCompareBool(this->value, other.value, Py_LE);
+ }
+
+ private:
+ using Base_ = PairingHeapNodeBase;
+ };
+
+
+
+ template<
+ typename TI, // type of items stored in the node
+ typename TV // type of values associated with the stored item
+ // Assume TV is a comparable type
+ >
+ class PairingHeap
+ {
+ public:
+ using HeapNodeType = PairingHeapNode;
+
+ // Constructor
+ explicit PairingHeap()
+ : root(nullptr) {
+ }
+
+ // Copy constructor
+ PairingHeap(PairingHeap const *other)
+ : root(nullptr) {
+ for (auto const& it: other->nodes) {
+ push(it.first, it.second->value);
+ }
+ }
+
+ // Destructor
+ virtual ~PairingHeap() {
+ for (auto const& it: nodes) {
+ delete it.second;
+ }
+ }
+
+ // Return true if the heap is empty, else false
+ bool empty() const {
+ return root == nullptr;
+ }
+
+ // Return true if the heap is not empty, else false
+ explicit operator bool() const {
+ return root != nullptr;
+ }
+
+ // Insert an item into the heap with specified value (priority)
+ void push(const TI &some_item, const TV &some_value) {
+ if (contains(some_item)) {
+ throw std::invalid_argument("item already in the heap");
+ }
+ PairingHeapNode *p = new PairingHeapNode(some_item, some_value);
+ nodes[some_item] = p;
+ root = empty() ? p : HeapNodeType::_merge(root, p);
+ }
+
+ // Return the top pair (item, value) of the heap
+ std::pair top() const {
+ if (empty()) {
+ throw std::domain_error("trying to access the top of an empty heap");
+ }
+ return std::make_pair(root->item, root->value);
+ }
+
+ // Return the top item of the heap
+ TI top_item() const {
+ if (empty()) {
+ throw std::domain_error("trying to access the top of an empty heap");
+ }
+ return root->item;
+ }
+
+ // Return the top value of the heap
+ TV top_value() const {
+ if (empty()) {
+ throw std::domain_error("trying to access the top of an empty heap");
+ }
+ return root->value;
+ }
+
+ // Remove the top element from the heap. Do nothing if empty
+ void pop() {
+ if (not empty()) {
+ PairingHeapNode *p = root->child;
+ nodes.erase(root->item);
+ delete root;
+ root = HeapNodeType::_pair(p);
+ }
+ }
+
+ // Decrease the value of specified item
+ // If the item is not in the heap, push it
+ void decrease(const TI &some_item, const TV &new_value) {
+ if (contains(some_item)) {
+ PairingHeapNode *p = nodes[some_item];
+ if (p->value <= new_value) {
+ throw std::invalid_argument("the new value must be less than the current value");
+ }
+ p->value = new_value;
+ if (p->prev != nullptr) {
+ HeapNodeType::_unlink(p);
+ root = HeapNodeType::_merge(root, p);
+ }
+ } else {
+ push(some_item, new_value);
+ }
+ }
+
+ // Check if specified item is in the heap
+ bool contains(TI const& some_item) const {
+ return nodes.find(some_item) != nodes.end();
+ }
+
+ // Return the value associated with the item
+ TV value(const TI &some_item) const {
+ auto it = nodes.find(some_item);
+ if (it == nodes.end()) {
+ throw std::invalid_argument("the specified item is not in the heap");
+ }
+ return it->second->value;
+ }
+
+ // Return the number of items in the heap
+ size_t size() const {
+ return nodes.size();
+ }
+
+ private:
+
+ // Pointer to the top of the heap
+ PairingHeapNode *root;
+
+ // Map used to access stored items
+ std::unordered_map *> nodes;
+
+ }; // end class PairingHeap
+
+} // end namespace pairing_heap
+
+#endif
diff --git a/src/sage/data_structures/pairing_heap.pxd b/src/sage/data_structures/pairing_heap.pxd
new file mode 100644
index 00000000000..d749cc7ec31
--- /dev/null
+++ b/src/sage/data_structures/pairing_heap.pxd
@@ -0,0 +1,86 @@
+# ******************************************************************************
+# Copyright (C) 2024 David Coudert
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 2 of the License, or
+# (at your option) any later version.
+# https://www.gnu.org/licenses/
+# ******************************************************************************
+
+from cpython cimport PyObject
+from libcpp.pair cimport pair
+from sage.data_structures.bitset_base cimport bitset_t
+
+
+# ==============================================================================
+# Interface to pairing heap data structure from ./pairing_heap.h
+# ==============================================================================
+
+cdef extern from "./pairing_heap.h" namespace "pairing_heap":
+ cdef cppclass PairingHeap[TypeOfItem, TypeOfValue]:
+ PairingHeap() except +
+ PairingHeap(PairingHeap[TypeOfItem, TypeOfValue]) except +
+ bint empty()
+ void push(TypeOfItem, TypeOfValue) except +
+ pair[TypeOfItem, TypeOfValue] top() except +
+ TypeOfItem top_item() except +
+ TypeOfValue top_value() except +
+ void pop() except +
+ void decrease(TypeOfItem, TypeOfValue) except +
+ bint contains(TypeOfItem)
+ TypeOfValue value(TypeOfItem) except +
+
+ cdef cppclass PairingHeapNodePy:
+ PyObject * value # value associated with the item
+ PairingHeapNodePy * prev # Previous sibling of the node or parent
+ PairingHeapNodePy * next # Next sibling of the node
+ PairingHeapNodePy * child # First child of the node
+
+ @staticmethod
+ PairingHeapNodePy * _merge(PairingHeapNodePy * a, PairingHeapNodePy * b) except +
+
+ @staticmethod
+ PairingHeapNodePy * _pair(PairingHeapNodePy * p) except +
+
+ @staticmethod
+ void _link(PairingHeapNodePy * a, PairingHeapNodePy * b)
+
+ @staticmethod
+ void _unlink(PairingHeapNodePy * p)
+
+
+# ==============================================================================
+# Pairing heap data structure with fixed capacity n
+# ==============================================================================
+
+cdef class PairingHeap_class:
+ cdef size_t n # maximum number of items
+ cdef PairingHeapNodePy * root # pointer to the top of the heap
+ cdef PairingHeapNodePy * nodes # array of size n to store items
+ cdef size_t number_of_items # number of active items
+ cpdef bint empty(self) noexcept
+ cpdef bint full(self) noexcept
+ cpdef size_t capacity(self) noexcept
+ cpdef size_t size(self) noexcept
+ cpdef tuple top(self)
+ cpdef object top_value(self)
+ cpdef void pop(self) noexcept
+
+
+cdef class PairingHeap_of_n_integers(PairingHeap_class):
+ cdef bitset_t active # bitset to identify active items
+ cpdef void push(self, size_t item, object value) except *
+ cpdef size_t top_item(self) except *
+ cpdef void decrease(self, size_t item, object new_value) except *
+ cpdef object value(self, size_t item)
+
+
+cdef class PairingHeap_of_n_hashables(PairingHeap_class):
+ cdef list _int_to_item # mapping from integers to items
+ cdef dict _item_to_int # mapping from items to integers
+ cdef list free_idx # list of free indexes
+ cpdef void push(self, object item, object value) except *
+ cpdef object top_item(self)
+ cpdef void decrease(self, object item, object new_value) except *
+ cpdef object value(self, object item)
diff --git a/src/sage/data_structures/pairing_heap.pyx b/src/sage/data_structures/pairing_heap.pyx
new file mode 100644
index 00000000000..ec08be43652
--- /dev/null
+++ b/src/sage/data_structures/pairing_heap.pyx
@@ -0,0 +1,1462 @@
+# distutils: language = c++
+r"""
+Pairing Heap
+
+This module proposes several implementations of the pairing heap data structure
+[FSST1986]_. See the :wikipedia:`Pairing_heap` for more information on this
+min-heap data structure.
+
+- :class:`PairingHeap_of_n_integers`: a pairing heap data structure with fixed
+ capacity `n`. Its items are integers in the range `[0, n-1]`. Values can be of
+ any type equipped with a comparison method (``<=``).
+
+- :class:`PairingHeap_of_n_hashables`: a pairing heap data structure with fixed
+ capacity `n`. Its items can be of any hashable type. Values can be of any type
+ equipped with a comparison method (``<=``).
+
+- ``PairingHeap``: interface to a pairing heap data structure written in C++.
+ The advantages of this data structure are that: its capacity is unbounded;
+ items can be of any hashable type equipped with a hashing method that can be
+ supported by ``std::unordered_map``; values can be of any specified type
+ equipped with a comparison method (``<=``). This data structure is for
+ internal use and therefore cannot be accessed from a shell.
+
+EXAMPLES:
+
+Pairing heap of `n` integers in the range `[0, n-1]`::
+
+ sage: from sage.data_structures.pairing_heap import PairingHeap_of_n_integers
+ sage: P = PairingHeap_of_n_integers(10); P
+ PairingHeap_of_n_integers: capacity 10, size 0
+ sage: P.push(1, 3)
+ sage: P.push(2, 2)
+ sage: P
+ PairingHeap_of_n_integers: capacity 10, size 2
+ sage: P.top()
+ (2, 2)
+ sage: P.decrease(1, 1)
+ sage: P.top()
+ (1, 1)
+ sage: P.pop()
+ sage: P.top()
+ (2, 2)
+
+ sage: P = PairingHeap_of_n_integers(10)
+ sage: P.push(1, (2, 'a'))
+ sage: P.push(2, (2, 'b'))
+ sage: P.top()
+ (1, (2, 'a'))
+
+Pairing heap of `n` hashables::
+
+ sage: from sage.data_structures.pairing_heap import PairingHeap_of_n_hashables
+ sage: P = PairingHeap_of_n_hashables(10); P
+ PairingHeap_of_n_hashables: capacity 10, size 0
+ sage: P.push(1, 3)
+ sage: P.push('b', 2)
+ sage: P.push((1, 'abc'), 4)
+ sage: P.top()
+ ('b', 2)
+ sage: P.decrease((1, 'abc'), 1)
+ sage: P.top()
+ ((1, 'abc'), 1)
+ sage: P.pop()
+ sage: P.top()
+ ('b', 2)
+
+ sage: # needs sage.graphs
+ sage: P = PairingHeap_of_n_hashables(10)
+ sage: P.push(('a', 1), (2, 'b'))
+ sage: P.push(2, (2, 'a'))
+ sage: g = Graph(2, immutable=True)
+ sage: P.push(g, (3, 'z'))
+ sage: P.top()
+ (2, (2, 'a'))
+ sage: P.decrease(g, (1, 'z'))
+ sage: P.top()
+ (Graph on 2 vertices, (1, 'z'))
+ sage: while P:
+ ....: print(P.top())
+ ....: P.pop()
+ (Graph on 2 vertices, (1, 'z'))
+ (2, (2, 'a'))
+ (('a', 1), (2, 'b'))
+"""
+# ******************************************************************************
+# Copyright (C) 2024 David Coudert
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 2 of the License, or
+# (at your option) any later version.
+# https://www.gnu.org/licenses/
+# ******************************************************************************
+
+
+from libcpp.pair cimport pair
+from cpython.ref cimport PyObject, Py_INCREF, Py_XDECREF
+from cysignals.signals cimport sig_on, sig_off, sig_check
+from cysignals.memory cimport check_allocarray, sig_free
+from sage.data_structures.bitset_base cimport (bitset_init, bitset_free,
+ bitset_add, bitset_remove,
+ bitset_in)
+from sage.misc.prandom import shuffle
+
+
+# ==============================================================================
+# Class PairingHeap_class
+# ==============================================================================
+
+cdef class PairingHeap_class:
+ r"""
+ Common class and methods for :class:`PairingHeap_of_n_integers` and
+ :class:`PairingHeap_of_n_hashables`.
+ """
+
+ def __repr__(self):
+ r"""
+ Return a string representing ``self``.
+
+ EXAMPLES::
+
+ sage: from sage.data_structures.pairing_heap import PairingHeap_of_n_integers
+ sage: P = PairingHeap_of_n_integers(5); P
+ PairingHeap_of_n_integers: capacity 5, size 0
+ sage: P.push(1, 2)
+ sage: P
+ PairingHeap_of_n_integers: capacity 5, size 1
+ """
+ return f"{type(self).__name__}: capacity {self.n}, size {len(self)}"
+
+ def __bool__(self):
+ r"""
+ Check whether ``self`` is not empty.
+
+ EXAMPLES::
+
+ sage: from sage.data_structures.pairing_heap import PairingHeap_of_n_integers
+ sage: P = PairingHeap_of_n_integers(5)
+ sage: 'not empty' if P else 'empty'
+ 'empty'
+ sage: P.push(1, 2)
+ sage: 'not empty' if P else 'empty'
+ 'not empty'
+ """
+ return self.root != NULL
+
+ cpdef bint empty(self) noexcept:
+ r"""
+ Check whether the heap is empty.
+
+ EXAMPLES::
+
+ sage: from sage.data_structures.pairing_heap import PairingHeap_of_n_integers
+ sage: P = PairingHeap_of_n_integers(5)
+ sage: P.empty()
+ True
+ sage: P.push(1, 2)
+ sage: P.empty()
+ False
+ """
+ return self.root == NULL
+
+ cpdef bint full(self) noexcept:
+ r"""
+ Check whether the heap is full.
+
+ EXAMPLES::
+
+ sage: from sage.data_structures.pairing_heap import PairingHeap_of_n_integers
+ sage: P = PairingHeap_of_n_integers(2)
+ sage: P.full()
+ False
+ sage: P.push(0, 2)
+ sage: P.push(1, 3)
+ sage: P.full()
+ True
+ """
+ return self.n == self.number_of_items
+
+ cpdef size_t capacity(self) noexcept:
+ r"""
+ Return the maximum capacity of the heap.
+
+ EXAMPLES::
+
+ sage: from sage.data_structures.pairing_heap import PairingHeap_of_n_integers
+ sage: P = PairingHeap_of_n_integers(5)
+ sage: P.capacity()
+ 5
+ sage: P.push(1, 2)
+ sage: P.capacity()
+ 5
+ """
+ return self.n
+
+ cpdef size_t size(self) noexcept:
+ r"""
+ Return the number of items in the heap.
+
+ EXAMPLES::
+
+ sage: from sage.data_structures.pairing_heap import PairingHeap_of_n_integers
+ sage: P = PairingHeap_of_n_integers(5)
+ sage: P.size()
+ 0
+ sage: P.push(1, 2)
+ sage: P.size()
+ 1
+
+ One may also use Python's ``__len__``::
+
+ sage: len(P)
+ 1
+ """
+ return self.number_of_items
+
+ def __len__(self):
+ r"""
+ Return the number of items in the heap.
+
+ EXAMPLES::
+
+ sage: from sage.data_structures.pairing_heap import PairingHeap_of_n_integers
+ sage: P = PairingHeap_of_n_integers(5)
+ sage: len(P)
+ 0
+ sage: P.push(1, 2)
+ sage: len(P)
+ 1
+ """
+ return self.number_of_items
+
+ cpdef tuple top(self):
+ r"""
+ Return the top pair (item, value) of the heap.
+
+ EXAMPLES::
+
+ sage: from sage.data_structures.pairing_heap import PairingHeap_of_n_integers
+ sage: P = PairingHeap_of_n_integers(5)
+ sage: P.push(1, 2)
+ sage: P.top()
+ (1, 2)
+ sage: P.push(3, 1)
+ sage: P.top()
+ (3, 1)
+
+ sage: P = PairingHeap_of_n_integers(3)
+ sage: P.top()
+ Traceback (most recent call last):
+ ...
+ ValueError: trying to access the top of an empty heap
+ """
+ raise NotImplementedError()
+
+ cpdef object top_value(self):
+ r"""
+ Return the value of the top item of the heap.
+
+ EXAMPLES::
+
+ sage: from sage.data_structures.pairing_heap import PairingHeap_of_n_integers
+ sage: P = PairingHeap_of_n_integers(5)
+ sage: P.push(1, 2)
+ sage: P.top()
+ (1, 2)
+ sage: P.top_value()
+ 2
+
+ sage: P = PairingHeap_of_n_integers(3)
+ sage: P.top_value()
+ Traceback (most recent call last):
+ ...
+ ValueError: trying to access the top of an empty heap
+ """
+ if not self:
+ raise ValueError("trying to access the top of an empty heap")
+ return self.root.value
+
+ cpdef void pop(self) noexcept:
+ r"""
+ Remove the top item from the heap.
+
+ If the heap is already empty, we do nothing.
+
+ EXAMPLES::
+
+ sage: from sage.data_structures.pairing_heap import PairingHeap_of_n_integers
+ sage: P = PairingHeap_of_n_integers(5); P
+ PairingHeap_of_n_integers: capacity 5, size 0
+ sage: P.push(1, 2); P
+ PairingHeap_of_n_integers: capacity 5, size 1
+ sage: P.pop(); P
+ PairingHeap_of_n_integers: capacity 5, size 0
+ sage: P.pop(); P
+ PairingHeap_of_n_integers: capacity 5, size 0
+ """
+ raise NotImplementedError()
+
+
+# ==============================================================================
+# Class PairingHeap_of_n_integers
+# ==============================================================================
+
+cdef class PairingHeap_of_n_integers(PairingHeap_class):
+ r"""
+ Pairing Heap for items in range `[0, n - 1]`.
+
+ EXAMPLES::
+
+ sage: from sage.data_structures.pairing_heap import PairingHeap_of_n_integers
+ sage: P = PairingHeap_of_n_integers(5); P
+ PairingHeap_of_n_integers: capacity 5, size 0
+ sage: P.push(1, 3)
+ sage: P.push(2, 2)
+ sage: P
+ PairingHeap_of_n_integers: capacity 5, size 2
+ sage: P.top()
+ (2, 2)
+ sage: P.decrease(1, 1)
+ sage: P.top()
+ (1, 1)
+ sage: P.pop()
+ sage: P.top()
+ (2, 2)
+
+ TESTS::
+
+ sage: from sage.data_structures.pairing_heap import PairingHeap_of_n_integers
+ sage: P = PairingHeap_of_n_integers(0)
+ Traceback (most recent call last):
+ ...
+ ValueError: the capacity of the heap must be strictly positive
+ sage: P = PairingHeap_of_n_integers(1); P
+ PairingHeap_of_n_integers: capacity 1, size 0
+ sage: P = PairingHeap_of_n_integers(5)
+ sage: P.push(11, 3)
+ Traceback (most recent call last):
+ ...
+ ValueError: item must be in range [0, 4]
+ """
+
+ def __init__(self, size_t n):
+ r"""
+ Construct the ``PairingHeap_of_n_integers`` where items are integers
+ from `0` to `n-1`.
+
+ INPUT:
+
+ - ``n`` -- strictly positive integer; the maximum number of items in the heap
+
+ EXAMPLES::
+
+ sage: from sage.data_structures.pairing_heap import PairingHeap_of_n_integers
+ sage: P = PairingHeap_of_n_integers(5); P
+ PairingHeap_of_n_integers: capacity 5, size 0
+ sage: P.push(1, 2); P
+ PairingHeap_of_n_integers: capacity 5, size 1
+ sage: P.push(2, 3); P
+ PairingHeap_of_n_integers: capacity 5, size 2
+ sage: P.pop(); P
+ PairingHeap_of_n_integers: capacity 5, size 1
+ sage: P.push(10, 1)
+ Traceback (most recent call last):
+ ...
+ ValueError: item must be in range [0, 4]
+ sage: PairingHeap_of_n_integers(1)
+ PairingHeap_of_n_integers: capacity 1, size 0
+
+ TESTS::
+
+ sage: PairingHeap_of_n_integers(0)
+ Traceback (most recent call last):
+ ...
+ ValueError: the capacity of the heap must be strictly positive
+ sage: P = PairingHeap_of_n_integers(10)
+ sage: P.push(1, 1); P.push(7, 0); P.push(0, 4); P.pop(); P.push(5, 5)
+ sage: TestSuite(P).run(skip="_test_pickling")
+ """
+ if not n:
+ raise ValueError("the capacity of the heap must be strictly positive")
+ self.n = n
+ self.root = NULL
+ self.nodes = check_allocarray(n, sizeof(PairingHeapNodePy))
+ bitset_init(self.active, n)
+ self.number_of_items = 0
+
+ def __dealloc__(self):
+ """
+ Deallocate ``self``.
+
+ EXAMPLES::
+
+ sage: from sage.data_structures.pairing_heap import PairingHeap_of_n_integers
+ sage: P = PairingHeap_of_n_integers(5)
+ sage: del P
+ """
+ sig_free(self.nodes)
+ bitset_free(self.active)
+
+ cpdef void push(self, size_t item, object value) except *:
+ r"""
+ Insert an item into the heap with specified value (priority).
+
+ INPUT:
+
+ - ``item`` -- nonnegative integer; the item to consider
+
+ - ``value`` -- the value associated with ``item``
+
+ EXAMPLES::
+
+ sage: from sage.data_structures.pairing_heap import PairingHeap_of_n_integers
+ sage: P = PairingHeap_of_n_integers(5)
+ sage: P.push(1, 2)
+ sage: P.top()
+ (1, 2)
+ sage: P.push(3, 1)
+ sage: P.top()
+ (3, 1)
+
+ TESTS::
+
+ sage: from sage.data_structures.pairing_heap import PairingHeap_of_n_integers
+ sage: P = PairingHeap_of_n_integers(5)
+ sage: P.push(1, 2)
+ sage: P.push(1, 2)
+ Traceback (most recent call last):
+ ...
+ ValueError: 1 is already in the heap
+ sage: P.push(11, 2)
+ Traceback (most recent call last):
+ ...
+ ValueError: item must be in range [0, 4]
+ sage: P.push(-1, 0)
+ Traceback (most recent call last):
+ ...
+ OverflowError: can't convert negative value to size_t
+ """
+ if item >= self.n:
+ raise ValueError(f"item must be in range [0, {self.n - 1}]")
+ if item in self:
+ raise ValueError(f"{item} is already in the heap")
+
+ cdef PairingHeapNodePy * p = self.nodes + item
+ Py_INCREF(value)
+ p.value = value
+ p.prev = p.next = p.child = NULL
+ if self.root == NULL:
+ self.root = p
+ else:
+ self.root = PairingHeapNodePy._merge(self.root, p)
+ bitset_add(self.active, item)
+ self.number_of_items += 1
+
+ cpdef tuple top(self):
+ r"""
+ Return the top pair (item, value) of the heap.
+
+ EXAMPLES::
+
+ sage: from sage.data_structures.pairing_heap import PairingHeap_of_n_integers
+ sage: P = PairingHeap_of_n_integers(5)
+ sage: P.push(1, 2)
+ sage: P.top()
+ (1, 2)
+ sage: P.push(3, 1)
+ sage: P.top()
+ (3, 1)
+
+ sage: P = PairingHeap_of_n_integers(3)
+ sage: P.top()
+ Traceback (most recent call last):
+ ...
+ ValueError: trying to access the top of an empty heap
+ """
+ if not self:
+ raise ValueError("trying to access the top of an empty heap")
+ return self.root - self.nodes, self.root.value
+
+ cpdef size_t top_item(self) except *:
+ r"""
+ Return the top item of the heap.
+
+ EXAMPLES::
+
+ sage: from sage.data_structures.pairing_heap import PairingHeap_of_n_integers
+ sage: P = PairingHeap_of_n_integers(5)
+ sage: P.push(1, 2)
+ sage: P.top()
+ (1, 2)
+ sage: P.top_item()
+ 1
+
+ sage: P = PairingHeap_of_n_integers(3)
+ sage: P.top_item()
+ Traceback (most recent call last):
+ ...
+ ValueError: trying to access the top of an empty heap
+ """
+ if not self:
+ raise ValueError("trying to access the top of an empty heap")
+ return self.root - self.nodes
+
+ cpdef void pop(self) noexcept:
+ r"""
+ Remove the top item from the heap.
+
+ If the heap is already empty, we do nothing.
+
+ EXAMPLES::
+
+ sage: from sage.data_structures.pairing_heap import PairingHeap_of_n_integers
+ sage: P = PairingHeap_of_n_integers(5); P
+ PairingHeap_of_n_integers: capacity 5, size 0
+ sage: P.push(1, 2); P
+ PairingHeap_of_n_integers: capacity 5, size 1
+ sage: P.push(2, 3); P
+ PairingHeap_of_n_integers: capacity 5, size 2
+ sage: P.pop(); P
+ PairingHeap_of_n_integers: capacity 5, size 1
+ sage: P.pop(); P
+ PairingHeap_of_n_integers: capacity 5, size 0
+ sage: P.pop(); P
+ PairingHeap_of_n_integers: capacity 5, size 0
+ """
+ if not self:
+ return
+ cdef size_t item = self.top_item()
+ Py_XDECREF(self.nodes[item].value)
+ bitset_remove(self.active, item)
+ self.number_of_items -= 1
+ self.root = PairingHeapNodePy._pair(self.root.child)
+
+ cpdef void decrease(self, size_t item, object new_value) except *:
+ r"""
+ Decrease the value of specified item.
+
+ This method is more permissive than it should as it can also be used to
+ push an item in the heap.
+
+ INPUT:
+
+ - ``item`` -- nonnegative integer; the item to consider
+
+ - ``new_value`` -- the new value for ``item``
+
+ EXAMPLES::
+
+ sage: from sage.data_structures.pairing_heap import PairingHeap_of_n_integers
+ sage: P = PairingHeap_of_n_integers(5)
+ sage: 3 in P
+ False
+ sage: P.decrease(3, 33)
+ sage: 3 in P
+ True
+ sage: P.top()
+ (3, 33)
+ sage: P.push(1, 10)
+ sage: P.top()
+ (1, 10)
+ sage: P.decrease(3, 7)
+ sage: P.top()
+ (3, 7)
+
+ TESTS::
+
+ sage: P = PairingHeap_of_n_integers(5)
+ sage: P.push(1, 3)
+ sage: P.decrease(1, 2)
+ sage: P.decrease(1, 2)
+ Traceback (most recent call last):
+ ...
+ ValueError: the new value must be less than the current value
+ """
+ if item >= self.n:
+ raise ValueError(f"item must be in range [0, {self.n - 1}]")
+ cdef PairingHeapNodePy * p
+ if bitset_in(self.active, item):
+ p = self.nodes + item
+ if p.value <= new_value:
+ raise ValueError("the new value must be less than the current value")
+ Py_XDECREF(p.value)
+ Py_INCREF(new_value)
+ p.value = new_value
+ if p.prev != NULL:
+ PairingHeapNodePy._unlink(p)
+ self.root = PairingHeapNodePy._merge(self.root, p)
+ else:
+ self.push(item, new_value)
+
+ def __contains__(self, size_t item):
+ r"""
+ Check whether the specified item is in the heap.
+
+ INPUT:
+
+ - ``item`` -- nonnegative integer; the item to consider
+
+ EXAMPLES::
+
+ sage: from sage.data_structures.pairing_heap import PairingHeap_of_n_integers
+ sage: P = PairingHeap_of_n_integers(5)
+ sage: 3 in P
+ False
+ sage: P.push(3, 33)
+ sage: 3 in P
+ True
+ sage: 100 in P
+ False
+ """
+ if item >= self.n:
+ return False
+ return bitset_in(self.active, item)
+
+ contains = __contains__
+
+ cpdef object value(self, size_t item):
+ r"""
+ Return the value associated with the item.
+
+ INPUT:
+
+ - ``item`` -- nonnegative integer; the item to consider
+
+ EXAMPLES::
+
+ sage: from sage.data_structures.pairing_heap import PairingHeap_of_n_integers
+ sage: P = PairingHeap_of_n_integers(5)
+ sage: P.push(3, 33)
+ sage: P.push(1, 10)
+ sage: P.value(3)
+ 33
+ sage: P.value(7)
+ Traceback (most recent call last):
+ ...
+ ValueError: 7 is not in the heap
+ """
+ if item not in self:
+ raise ValueError(f"{item} is not in the heap")
+ return self.nodes[item].value
+
+
+# ==============================================================================
+# Class PairingHeap_of_n_hashables
+# ==============================================================================
+
+cdef class PairingHeap_of_n_hashables(PairingHeap_class):
+ r"""
+ Pairing Heap for `n` hashable items.
+
+ EXAMPLES::
+
+ sage: from sage.data_structures.pairing_heap import PairingHeap_of_n_hashables
+ sage: P = PairingHeap_of_n_hashables(5); P
+ PairingHeap_of_n_hashables: capacity 5, size 0
+ sage: P.push(1, 3)
+ sage: P.push('abc', 2); P
+ PairingHeap_of_n_hashables: capacity 5, size 2
+ sage: P.top()
+ ('abc', 2)
+ sage: P.decrease(1, 1)
+ sage: P.top()
+ (1, 1)
+ sage: P.pop()
+ sage: P.top()
+ ('abc', 2)
+
+ sage: P = PairingHeap_of_n_hashables(5)
+ sage: P.push(1, (2, 3))
+ sage: P.push('a', (2, 2))
+ sage: P.push('b', (3, 3))
+ sage: P.push('c', (2, 1))
+ sage: P.top()
+ ('c', (2, 1))
+ sage: P.push(Graph(2, immutable=True), (1, 7))
+ sage: P.top()
+ (Graph on 2 vertices, (1, 7))
+ sage: P.decrease('b', (1, 5))
+ sage: P.top()
+ ('b', (1, 5))
+
+ TESTS::
+
+ sage: from sage.data_structures.pairing_heap import PairingHeap_of_n_hashables
+ sage: P = PairingHeap_of_n_hashables(0)
+ Traceback (most recent call last):
+ ...
+ ValueError: the capacity of the heap must be strictly positive
+ sage: P = PairingHeap_of_n_hashables(1); P
+ PairingHeap_of_n_hashables: capacity 1, size 0
+ sage: P.push(11, 3)
+ sage: P.push(12, 4)
+ Traceback (most recent call last):
+ ...
+ ValueError: the heap is full
+
+ sage: P = PairingHeap_of_n_hashables(10)
+ sage: P.push(1, 'John')
+ sage: P.push(4, 42)
+ Traceback (most recent call last):
+ ...
+ TypeError: unsupported operand parent(s) for >=: 'Integer Ring' and ''
+ """
+
+ def __init__(self, size_t n):
+ r"""
+ Construct the ``PairingHeap_of_n_hashables``.
+
+ This pairing heap has a maximum capacity of `n` items and each item is a
+ hashable object.
+
+ INPUT:
+
+ - ``n`` -- strictly positive integer; the maximum number of items in the heap
+
+ EXAMPLES::
+
+ sage: from sage.data_structures.pairing_heap import PairingHeap_of_n_hashables
+ sage: P = PairingHeap_of_n_hashables(2); P
+ PairingHeap_of_n_hashables: capacity 2, size 0
+ sage: P.push(1, 2)
+ sage: P
+ PairingHeap_of_n_hashables: capacity 2, size 1
+ sage: P.push(2, 3)
+ sage: P
+ PairingHeap_of_n_hashables: capacity 2, size 2
+ sage: P.full()
+ True
+ sage: P.push(10, 1)
+ Traceback (most recent call last):
+ ...
+ ValueError: the heap is full
+ sage: P.pop()
+ sage: P
+ PairingHeap_of_n_hashables: capacity 2, size 1
+ sage: P.push(10, 1)
+
+ TESTS::
+
+ sage: P = PairingHeap_of_n_hashables(0)
+ Traceback (most recent call last):
+ ...
+ ValueError: the capacity of the heap must be strictly positive
+ sage: P = PairingHeap_of_n_hashables(1); P
+ PairingHeap_of_n_hashables: capacity 1, size 0
+ sage: P = PairingHeap_of_n_hashables(6)
+ sage: P.push(1, -0.5); P.push(frozenset(), 1); P.pop(); P.push('a', 3.5)
+ sage: TestSuite(P).run(skip="_test_pickling")
+ """
+ if not n:
+ raise ValueError("the capacity of the heap must be strictly positive")
+ self.n = n
+ self.root = NULL
+ self.nodes = check_allocarray(n, sizeof(PairingHeapNodePy))
+ self.number_of_items = 0
+ self._int_to_item = [None] * n
+ self._item_to_int = dict()
+ self.free_idx = list(range(n))
+
+ def __dealloc__(self):
+ """
+ Deallocate ``self``.
+
+ EXAMPLES::
+
+ sage: from sage.data_structures.pairing_heap import PairingHeap_of_n_integers
+ sage: P = PairingHeap_of_n_integers(5)
+ sage: del P
+ """
+ sig_free(self.nodes)
+
+ cpdef void push(self, object item, object value) except *:
+ r"""
+ Insert an item into the heap with specified value (priority).
+
+ INPUT:
+
+ - ``item`` -- a hashable object; the item to add
+
+ - ``value`` -- the value associated with ``item``
+
+ EXAMPLES::
+
+ sage: from sage.data_structures.pairing_heap import PairingHeap_of_n_hashables
+ sage: P = PairingHeap_of_n_hashables(5)
+ sage: P.push(1, 2)
+ sage: P.top()
+ (1, 2)
+ sage: P.push(3, 1)
+ sage: P.top()
+ (3, 1)
+
+ TESTS::
+
+ sage: from sage.data_structures.pairing_heap import PairingHeap_of_n_hashables
+ sage: P = PairingHeap_of_n_hashables(2)
+ sage: P.push(1, 2)
+ sage: P.push(1, 2)
+ Traceback (most recent call last):
+ ...
+ ValueError: 1 is already in the heap
+ sage: P.push(11, 2)
+ sage: P.push(7, 5)
+ Traceback (most recent call last):
+ ...
+ ValueError: the heap is full
+ """
+ if item in self:
+ raise ValueError(f"{item} is already in the heap")
+ if self.full():
+ raise ValueError("the heap is full")
+
+ cdef size_t idx = self.free_idx.pop()
+ self._int_to_item[idx] = item
+ self._item_to_int[item] = idx
+ cdef PairingHeapNodePy * p = self.nodes + idx
+ Py_INCREF(value)
+ p.value = value
+ p.prev = p.next = p.child = NULL
+ if self.root == NULL:
+ self.root = p
+ else:
+ self.root = PairingHeapNodePy._merge(self.root, p)
+ self.number_of_items += 1
+
+ cpdef tuple top(self):
+ r"""
+ Return the top pair (item, value) of the heap.
+
+ EXAMPLES::
+
+ sage: from sage.data_structures.pairing_heap import PairingHeap_of_n_hashables
+ sage: P = PairingHeap_of_n_hashables(5)
+ sage: P.push(1, 2)
+ sage: P.top()
+ (1, 2)
+ sage: P.push(3, 1)
+ sage: P.top()
+ (3, 1)
+
+ sage: P = PairingHeap_of_n_hashables(3)
+ sage: P.top()
+ Traceback (most recent call last):
+ ...
+ ValueError: trying to access the top of an empty heap
+ """
+ if not self:
+ raise ValueError("trying to access the top of an empty heap")
+ cdef size_t idx = self.root - self.nodes
+ return self._int_to_item[idx], self.root.value
+
+ cpdef object top_item(self):
+ r"""
+ Return the top item of the heap.
+
+ EXAMPLES::
+
+ sage: from sage.data_structures.pairing_heap import PairingHeap_of_n_hashables
+ sage: P = PairingHeap_of_n_hashables(5)
+ sage: P.push(1, 2)
+ sage: P.top()
+ (1, 2)
+ sage: P.top_item()
+ 1
+
+ sage: P = PairingHeap_of_n_hashables(3)
+ sage: P.top_item()
+ Traceback (most recent call last):
+ ...
+ ValueError: trying to access the top of an empty heap
+ """
+ if not self:
+ raise ValueError("trying to access the top of an empty heap")
+ cdef size_t idx = self.root - self.nodes
+ return self._int_to_item[idx]
+
+ cpdef void pop(self) noexcept:
+ r"""
+ Remove the top item from the heap.
+
+ If the heap is already empty, we do nothing.
+
+ EXAMPLES::
+
+ sage: from sage.data_structures.pairing_heap import PairingHeap_of_n_hashables
+ sage: P = PairingHeap_of_n_hashables(5); len(P)
+ 0
+ sage: P.push(1, 2); len(P)
+ 1
+ sage: P.push(2, 3); len(P)
+ 2
+ sage: P.pop(); len(P)
+ 1
+ sage: P.pop(); len(P)
+ 0
+ sage: P.pop(); len(P)
+ 0
+ """
+ if not self:
+ return
+ cdef object item = self.top_item()
+ cdef size_t idx = self._item_to_int[item]
+ Py_XDECREF(self.nodes[idx].value)
+ self.free_idx.append(idx)
+ del self._item_to_int[item]
+ self.number_of_items -= 1
+ self.root = PairingHeapNodePy._pair(self.root.child)
+
+ cpdef void decrease(self, object item, object new_value) except *:
+ r"""
+ Decrease the value of specified item.
+
+ This method is more permissive than it should as it can also be used to
+ push an item in the heap.
+
+ INPUT:
+
+ - ``item`` -- the item to consider
+
+ - ``new_value`` -- the new value for ``item``
+
+ EXAMPLES::
+
+ sage: from sage.data_structures.pairing_heap import PairingHeap_of_n_hashables
+ sage: P = PairingHeap_of_n_hashables(5)
+ sage: 3 in P
+ False
+ sage: P.decrease(3, 33)
+ sage: 3 in P
+ True
+ sage: P.top()
+ (3, 33)
+ sage: P.push(1, 10)
+ sage: P.top()
+ (1, 10)
+ sage: P.decrease(3, 7)
+ sage: P.top()
+ (3, 7)
+
+ TESTS::
+
+ sage: P = PairingHeap_of_n_hashables(5)
+ sage: P.push(1, 3)
+ sage: P.decrease(1, 2)
+ sage: P.decrease(1, 2)
+ Traceback (most recent call last):
+ ...
+ ValueError: the new value must be less than the current value
+ """
+ cdef PairingHeapNodePy * p
+ cdef size_t idx
+ if item in self:
+ idx = self._item_to_int[item]
+ p = self.nodes + idx
+ if p.value <= new_value:
+ raise ValueError("the new value must be less than the current value")
+ Py_XDECREF(p.value)
+ Py_INCREF(new_value)
+ p.value = new_value
+ if p.prev != NULL:
+ PairingHeapNodePy._unlink(p)
+ self.root = PairingHeapNodePy._merge(self.root, p)
+ else:
+ self.push(item, new_value)
+
+ def __contains__(self, object item):
+ r"""
+ Check whether the specified item is in the heap.
+
+ INPUT:
+
+ - ``item`` -- the item to consider
+
+ EXAMPLES::
+
+ sage: from sage.data_structures.pairing_heap import PairingHeap_of_n_hashables
+ sage: P = PairingHeap_of_n_hashables(5)
+ sage: 3 in P
+ False
+ sage: P.push(3, 33)
+ sage: 3 in P
+ True
+ sage: 100 in P
+ False
+ """
+ return item in self._item_to_int
+
+ contains = __contains__
+
+ cpdef object value(self, object item):
+ r"""
+ Return the value associated with the item.
+
+ INPUT:
+
+ - ``item`` -- the item to consider
+
+ EXAMPLES::
+
+ sage: from sage.data_structures.pairing_heap import PairingHeap_of_n_hashables
+ sage: P = PairingHeap_of_n_hashables(5)
+ sage: P.push(3, 33)
+ sage: P.push(1, 10)
+ sage: P.value(3)
+ 33
+ sage: P.value(7)
+ Traceback (most recent call last):
+ ...
+ ValueError: 7 is not in the heap
+ """
+ if item not in self:
+ raise ValueError(f"{item} is not in the heap")
+ cdef size_t idx = self._item_to_int[item]
+ return self.nodes[idx].value
+
+
+# ==============================================================================
+# Methods to check the validity of the pairing heaps
+# ==============================================================================
+
+def _test_PairingHeap_from_C(n=100):
+ r"""
+ Test :class:`~sage.data_structures.pairing_heap.PairingHeap`.
+
+ INPUT:
+
+ - ``n`` -- a strictly positive integer (default: 100); the maximum capacity
+ of the heap
+
+ TESTS::
+
+ sage: from sage.data_structures.pairing_heap import _test_PairingHeap_from_C
+ sage: _test_PairingHeap_from_C(100)
+ """
+ from sage.misc.prandom import randint, shuffle
+ sig_on()
+ cdef PairingHeap[size_t, size_t] PH = PairingHeap[size_t, size_t]()
+ sig_off()
+
+ # Initialize a list of tuples (value, item) randomly ordered
+ items = list(range(n))
+ values = list(range(n))
+ shuffle(items)
+ shuffle(values)
+ cdef list Lref = list(zip(values, items))
+
+ for value, item in Lref:
+ PH.push(item, value)
+ sig_check()
+
+ L = []
+ while not PH.empty():
+ item, value = PH.top()
+ L.append((value, item))
+ PH.pop()
+ sig_check()
+
+ if L != sorted(Lref):
+ raise ValueError('the order is not good')
+
+ # Test decrease key operations. We first push items in the heap with an
+ # excess of k in the value. Then we decrease the keys in a random order by
+ # random values until returning to the original values. We finally check the
+ # validity of the resulting ordering.
+ k = 10
+ dec = {item: k for item in items}
+ shuffle(Lref)
+ for value, item in Lref:
+ PH.push(item, value + k)
+ sig_check()
+
+ L = list(items)
+ while L:
+ i = randint(0, len(L) - 1)
+ item = L[i]
+ d = randint(1, dec[item])
+ dec[item] -= d
+ if not dec[item]:
+ L[i] = L[-1]
+ L.pop()
+ PH.decrease(item, PH.value(item) - d)
+ sig_check()
+
+ L = []
+ while not PH.empty():
+ item, value = PH.top()
+ L.append((value, item))
+ PH.pop()
+ sig_check()
+
+ if L != sorted(Lref):
+ raise ValueError('the order is not good')
+
+ # Different cost function
+ from sage.functions.trig import sin, cos
+ sig_on()
+ cdef PairingHeap[size_t, pair[size_t, size_t]] HH = PairingHeap[size_t, pair[size_t, size_t]]()
+ sig_off()
+
+ for i in range(n):
+ HH.push(i, (sin(i), cos(i)))
+ sig_check()
+
+ L = []
+ while not HH.empty():
+ L.append(HH.top())
+ HH.pop()
+ sig_check()
+
+ for (u, cu), (v, cv) in zip(L, L[1:]):
+ if cu > cv:
+ print(u, cu, v, cv)
+
+ # We finally show that an error is raised when trying to access the top of
+ # an empty heap
+ try:
+ _ = HH.top()
+ print("something goes wrong, the error has not been raised")
+ except ValueError as msg:
+ # The error has been properly handled
+ pass
+
+ try:
+ _ = HH.top_item()
+ print("something goes wrong, the error has not been raised")
+ except ValueError as msg:
+ # The error has been properly handled
+ pass
+
+ try:
+ _ = HH.top_value()
+ print("something goes wrong, the error has not been raised")
+ except ValueError as msg:
+ # The error has been properly handled
+ pass
+
+ # Or to get the value associated to an item that is not in the heap
+ try:
+ _ = HH.value(123)
+ print("something goes wrong, the error has not been raised")
+ except ValueError as msg:
+ # The error has been properly handled
+ pass
+
+
+def _test_PairingHeap_of_n_integers(n=100):
+ r"""
+ Test :class:`~sage.data_structures.pairing_heap.PairingHeap_of_n_integers`.
+
+ INPUT:
+
+ - ``n`` -- a strictly positive integer (default: 100); the maximum capacity
+ of the heap
+
+ TESTS::
+
+ sage: from sage.data_structures.pairing_heap import _test_PairingHeap_of_n_integers
+ sage: _test_PairingHeap_of_n_integers(100)
+ """
+ from sage.misc.prandom import randint, shuffle
+
+ sig_on()
+ cdef PairingHeap_of_n_integers P = PairingHeap_of_n_integers(n)
+ sig_off()
+
+ # Initialize a list of tuples (value, item) randomly ordered
+ cdef list items = list(range(n))
+ cdef list values = list(range(n))
+ shuffle(items)
+ shuffle(values)
+ cdef list Lref = list(zip(values, items))
+
+ cdef int value, item
+ for value, item in Lref:
+ P.push(item, value)
+ sig_check()
+
+ cdef list L = []
+ while P:
+ item, value = P.top()
+ L.append((value, item))
+ P.pop()
+ sig_check()
+
+ if L != sorted(Lref):
+ raise ValueError('the order is not good')
+
+ # Test decrease key operations. We first push items in the heap with an
+ # excess of k in the value. Then we decrease the keys in a random order by
+ # random values until returning to the original values. We finally check the
+ # validity of the resulting ordering.
+ cdef int k = 10
+ cdef list dec = [k] * n
+ shuffle(Lref)
+ for value, item in Lref:
+ P.push(item, value + k)
+ sig_check()
+
+ L = list(items)
+ while L:
+ i = randint(0, len(L) - 1)
+ item = L[i]
+ d = randint(1, dec[item])
+ dec[item] -= d
+ if not dec[item]:
+ L[i] = L[-1]
+ L.pop()
+ P.decrease(item, P.value(item) - d)
+ sig_check()
+
+ L = []
+ while P:
+ item, value = P.top()
+ L.append((value, item))
+ P.pop()
+ sig_check()
+
+ if L != sorted(Lref):
+ raise ValueError('the order is not good')
+
+ # We finally show that an error is raised when trying to access the top of
+ # an empty heap
+ try:
+ _ = P.top()
+ print("something goes wrong, the error has not been raised")
+ except ValueError as msg:
+ # The error has been properly handled
+ pass
+
+ try:
+ _ = P.top_item()
+ print("something goes wrong, the error has not been raised")
+ except ValueError as msg:
+ # The error has been properly handled
+ pass
+
+ try:
+ _ = P.top_value()
+ print("something goes wrong, the error has not been raised")
+ except ValueError as msg:
+ # The error has been properly handled
+ pass
+
+ # Or to get the value associated to an item that is not in the heap
+ try:
+ _ = P.value(123)
+ print("something goes wrong, the error has not been raised")
+ except ValueError as msg:
+ # The error has been properly handled
+ pass
+
+
+def _test_PairingHeap_of_n_hashables(n=100):
+ r"""
+ Test :class:`~sage.data_structures.pairing_heap.PairingHeap_of_n_hashables`.
+
+ INPUT:
+
+ - ``n`` -- a strictly positive integer (default: 100); the maximum capacity
+ of the heap
+
+ TESTS::
+
+ sage: from sage.data_structures.pairing_heap import _test_PairingHeap_of_n_hashables
+ sage: _test_PairingHeap_of_n_hashables(100)
+ """
+ from sage.misc.prandom import randint, shuffle
+
+ sig_on()
+ cdef PairingHeap_of_n_hashables P = PairingHeap_of_n_hashables(n)
+ sig_off()
+
+ # Initialize a list of tuples (value, item) randomly ordered
+ cdef list items = [(str(i), i) for i in range(n)]
+ cdef list values = list(range(n))
+ shuffle(items)
+ shuffle(values)
+ cdef list Lref = list(zip(values, items))
+
+ for value, item in Lref:
+ P.push(item, value)
+ sig_check()
+
+ cdef list L = []
+ while P:
+ item, value = P.top()
+ L.append((value, item))
+ P.pop()
+ sig_check()
+
+ if L != sorted(Lref):
+ raise ValueError('the order is not good')
+
+ # Test decrease key operations. We first push items in the heap with an
+ # excess of k in the value. Then we decrease the keys in a random order by
+ # random values until returning to the original values. We finally check the
+ # validity of the resulting ordering.
+ cdef int k = 10
+ cdef dict dec = {item: k for item in items}
+ shuffle(Lref)
+ for value, item in Lref:
+ P.push(item, value + k)
+ sig_check()
+
+ L = list(items)
+ while L:
+ i = randint(0, len(L) - 1)
+ item = L[i]
+ d = randint(1, dec[item])
+ dec[item] -= d
+ if not dec[item]:
+ L[i] = L[-1]
+ L.pop()
+ P.decrease(item, P.value(item) - d)
+ sig_check()
+
+ L = []
+ while P:
+ item, value = P.top()
+ L.append((value, item))
+ P.pop()
+ sig_check()
+
+ if L != sorted(Lref):
+ raise ValueError('the order is not good')
+
+ # We finally show that an error is raised when trying to access the top of
+ # an empty heap
+ try:
+ _ = P.top()
+ print("something goes wrong, the error has not been raised")
+ except ValueError as msg:
+ # The error has been properly handled
+ pass
+
+ try:
+ _ = P.top_item()
+ print("something goes wrong, the error has not been raised")
+ except ValueError as msg:
+ # The error has been properly handled
+ pass
+
+ try:
+ _ = P.top_value()
+ print("something goes wrong, the error has not been raised")
+ except ValueError as msg:
+ # The error has been properly handled
+ pass
+
+ # Or to get the value associated to an item that is not in the heap
+ try:
+ _ = P.value(123)
+ print("something goes wrong, the error has not been raised")
+ except ValueError as msg:
+ # The error has been properly handled
+ pass
+
+
+def _compare_heaps(n=100, verbose=False):
+ r"""
+ Check that the heaps behave the same.
+
+ This method selects a list of instructions: push items in some order,
+ decrease the values of the items in some order, extract all items in order.
+ Then it applies the same instructions to a ``PairingHeap``, a
+ :class:`PairingHeap_of_n_integers` and a
+ :class:`PairingHeap_of_n_hashables`. It checks that all heaps report the
+ list of items in the same order and it measures the running time.
+
+ INPUT:
+
+ - ``n`` -- a strictly positive integer (default: 100); the maximum capacity
+ of the heap
+
+ - ``verbose`` -- boolean (default: ``False``); whether to display
+ information about the running times
+
+ EXAMPLES::
+
+ sage: from sage.data_structures.pairing_heap import _compare_heaps
+ sage: _compare_heaps(n=100)
+ sage: _compare_heaps(n=100, verbose=True) # random
+ PairingHeap_of_n_integers: 7.800000000024454e-05
+ PairingHeap_of_n_hashables: 9.400000000026054e-05
+ PairingHeap (C++): 6.899999999987472e-05
+ sage: _compare_heaps(1000000, verbose=True) # not tested (long time), random
+ PairingHeap_of_n_integers: 1.5106779999999995
+ PairingHeap_of_n_hashables: 4.998040000000001
+ PairingHeap (C++): 1.7841750000000012
+ """
+ from sage.misc.prandom import shuffle
+ from sage.misc.timing import cputime
+
+ items = list(range(n))
+ values = list(range(n))
+ shuffle(items)
+ shuffle(values)
+ Lref = list(zip(values, items))
+ k = 10
+ dec_order = list(items)
+ shuffle(dec_order)
+
+ t = cputime()
+ sig_on()
+ cdef PairingHeap_of_n_integers P = PairingHeap_of_n_integers(n)
+ sig_off()
+ for value, item in Lref:
+ P.push(item, value + k)
+ sig_check()
+ for item in dec_order:
+ P.decrease(item, P.value(item) - k)
+ sig_check()
+ LP = []
+ while P:
+ LP.append(P.top())
+ P.pop()
+ sig_check()
+ t = cputime(t)
+ if verbose:
+ print(f"PairingHeap_of_n_integers: {t}")
+
+ t = cputime()
+ sig_on()
+ cdef PairingHeap_of_n_hashables Q = PairingHeap_of_n_hashables(n)
+ sig_off()
+ for value, item in Lref:
+ Q.push(item, value + k)
+ sig_check()
+ for item in dec_order:
+ Q.decrease(item, Q.value(item) - k)
+ sig_check()
+ LQ = []
+ while Q:
+ LQ.append(Q.top())
+ Q.pop()
+ sig_check()
+ t = cputime(t)
+ if verbose:
+ print(f"PairingHeap_of_n_hashables: {t}")
+
+ t = cputime()
+ sig_on()
+ cdef PairingHeap[size_t, size_t] PH = PairingHeap[size_t, size_t]()
+ sig_off()
+ for value, item in Lref:
+ PH.push(item, value + k)
+ sig_check()
+ for item in dec_order:
+ PH.decrease(item, PH.value(item) - k)
+ sig_check()
+ LPH = []
+ while not PH.empty():
+ LPH.append(PH.top())
+ PH.pop()
+ sig_check()
+ t = cputime(t)
+ if verbose:
+ print(f"PairingHeap (C++): {t}")
+
+ if LPH != LP or LP != LQ:
+ print('something goes wrong')
diff --git a/src/sage/databases/db_class_polynomials.py b/src/sage/databases/db_class_polynomials.py
index 57acde7c05a..4362df56837 100644
--- a/src/sage/databases/db_class_polynomials.py
+++ b/src/sage/databases/db_class_polynomials.py
@@ -30,8 +30,8 @@
from .db_modular_polynomials import _dbz_to_integers
-disc_format = "%07d" # disc_length = 7
-level_format = "%03d" # level_length = 3
+disc_format = "%07d" # disc_length = 7
+level_format = "%03d" # level_length = 3
class ClassPolynomialDatabase:
@@ -52,7 +52,7 @@ def _dbpath(self, disc, level=1):
if level != 1:
raise NotImplementedError("Level (= %s) > 1 not yet implemented" % level)
n1 = 5000*((abs(disc)-1)//5000)
- s1 = disc_format % (n1+1) #_pad_int(n1+1, disc_length)
+ s1 = disc_format % (n1+1) # _pad_int(n1+1, disc_length)
s2 = disc_format % (n1+5000)
subdir = "%s-%s" % (s1, s2)
discstr = disc_format % abs(disc)
diff --git a/src/sage/dynamics/arithmetic_dynamics/meson.build b/src/sage/dynamics/arithmetic_dynamics/meson.build
index 9e26a72c874..7ba8b8b4068 100644
--- a/src/sage/dynamics/arithmetic_dynamics/meson.build
+++ b/src/sage/dynamics/arithmetic_dynamics/meson.build
@@ -1,4 +1,5 @@
py.install_sources(
+ '__init__.py',
'affine_ds.py',
'all.py',
'berkovich_ds.py',
diff --git a/src/sage/dynamics/arithmetic_dynamics/projective_ds.py b/src/sage/dynamics/arithmetic_dynamics/projective_ds.py
index f395214b516..591693e5af8 100644
--- a/src/sage/dynamics/arithmetic_dynamics/projective_ds.py
+++ b/src/sage/dynamics/arithmetic_dynamics/projective_ds.py
@@ -95,7 +95,7 @@ class initialization directly.
from sage.rings.morphism import RingHomomorphism_im_gens
from sage.rings.polynomial.multi_polynomial_ring_base import MPolynomialRing_base
from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing
-from sage.rings.polynomial.polynomial_ring import PolynomialRing_general
+from sage.rings.polynomial.polynomial_ring import PolynomialRing_generic
from sage.rings.quotient_ring import QuotientRing_generic
from sage.rings.rational_field import QQ
from sage.rings.real_mpfr import RealField
@@ -385,7 +385,7 @@ def __classcall_private__(cls, morphism_or_polys, domain=None, names=None):
polys = list(morphism_or_polys)
if len(polys) == 1:
raise ValueError("list/tuple must have at least 2 polynomials")
- test = lambda x: isinstance(x, (PolynomialRing_general, MPolynomialRing_base))
+ test = lambda x: isinstance(x, (PolynomialRing_generic, MPolynomialRing_base))
if not all(test(poly.parent()) for poly in polys):
try:
polys = [poly.lift() for poly in polys]
@@ -395,7 +395,7 @@ def __classcall_private__(cls, morphism_or_polys, domain=None, names=None):
# homogenize!
f = morphism_or_polys
aff_CR = f.parent()
- if (not isinstance(aff_CR, PolynomialRing_general) and not isinstance(aff_CR, FractionField_generic)
+ if (not isinstance(aff_CR, (PolynomialRing_generic, FractionField_generic))
and not (isinstance(aff_CR, MPolynomialRing_base) and aff_CR.ngens() == 1)):
msg = '{} is not a single variable polynomial or rational function'
raise ValueError(msg.format(f))
@@ -3533,7 +3533,7 @@ def affine_preperiodic_model(self, m, n, return_conjugation=False):
if hyperplane_found:
break
else:
- if isinstance(R, (PolynomialRing_general,
+ if isinstance(R, (PolynomialRing_generic,
MPolynomialRing_base,
FractionField_generic)):
# for polynomial rings, we can get an infinite family of hyperplanes
@@ -4597,7 +4597,7 @@ def preperiodic_points(self, m, n, **kwds):
for k in ZZ(n).divisors():
if ZZ(n/k).is_prime():
Sn.append(k)
- if isinstance(R, (PolynomialRing_general,
+ if isinstance(R, (PolynomialRing_generic,
MPolynomialRing_base)):
phi = FlatteningMorphism(CR)
flatCR = phi.codomain()
@@ -4954,7 +4954,7 @@ def periodic_points(self, n, minimal=True, formal=False, R=None, algorithm='vari
for k in ZZ(n).divisors():
if ZZ(n//k).is_prime():
Sn.append(k)
- if isinstance(R, (PolynomialRing_general,
+ if isinstance(R, (PolynomialRing_generic,
MPolynomialRing_base)):
phi = FlatteningMorphism(CR)
flatCR = phi.codomain()
@@ -5789,7 +5789,7 @@ def sigma_invariants(self, n, formal=False, embedding=None, type='point',
F = base_ring
if isinstance(base_ring, FractionField_generic):
if isinstance(base_ring.ring(), (MPolynomialRing_base,
- PolynomialRing_general)):
+ PolynomialRing_generic)):
f.normalize_coordinates()
f_ring = f.change_ring(base_ring.ring())
X = f_ring.periodic_points(n, minimal=False, formal=formal, return_scheme=True)
@@ -5892,7 +5892,7 @@ def sigma_invariants(self, n, formal=False, embedding=None, type='point',
base_ring = dom.base_ring()
if isinstance(base_ring, FractionField_generic):
base_ring = base_ring.ring()
- if isinstance(base_ring, (PolynomialRing_general,
+ if isinstance(base_ring, (PolynomialRing_generic,
MPolynomialRing_base)):
base_ring = base_ring.base_ring()
elif base_ring in FunctionFields():
diff --git a/src/sage/dynamics/complex_dynamics/meson.build b/src/sage/dynamics/complex_dynamics/meson.build
index d3961275d3e..ccde4866dd1 100644
--- a/src/sage/dynamics/complex_dynamics/meson.build
+++ b/src/sage/dynamics/complex_dynamics/meson.build
@@ -1,4 +1,5 @@
py.install_sources(
+ '__init__.py',
'all.py',
'mandel_julia.py',
subdir: 'sage/dynamics/complex_dynamics',
diff --git a/src/sage/dynamics/finite_dynamical_system_catalog.py b/src/sage/dynamics/finite_dynamical_system_catalog.py
old mode 100755
new mode 100644
diff --git a/src/sage/dynamics/meson.build b/src/sage/dynamics/meson.build
index 134cfd1a296..9ba62964e6c 100644
--- a/src/sage/dynamics/meson.build
+++ b/src/sage/dynamics/meson.build
@@ -1,4 +1,5 @@
py.install_sources(
+ '__init__.py',
'all.py',
'finite_dynamical_system.py',
'finite_dynamical_system_catalog.py',
diff --git a/src/sage/ext/fast_callable.pyx b/src/sage/ext/fast_callable.pyx
index 89c34b1f0fc..477f8608ef7 100644
--- a/src/sage/ext/fast_callable.pyx
+++ b/src/sage/ext/fast_callable.pyx
@@ -475,10 +475,11 @@ def fast_callable(x, domain=None, vars=None,
x = x.function(*vars)
if vars is None:
- from sage.rings.polynomial.polynomial_ring import PolynomialRing_general
+ from sage.rings.polynomial.polynomial_ring import PolynomialRing_generic
from sage.rings.polynomial.multi_polynomial_ring import MPolynomialRing_base
- if isinstance(x.parent(), PolynomialRing_general) or isinstance(x.parent(), MPolynomialRing_base):
- vars = x.parent().variable_names()
+ P = x.parent()
+ if isinstance(P, (PolynomialRing_generic, MPolynomialRing_base)):
+ vars = P.variable_names()
else:
# constant
vars = ()
diff --git a/src/sage/ext/meson.build b/src/sage/ext/meson.build
index 73d0e85101d..dc3026cec34 100644
--- a/src/sage/ext/meson.build
+++ b/src/sage/ext/meson.build
@@ -1,4 +1,5 @@
py.install_sources(
+ '__init__.py',
'all__sagemath_objects.py',
'ccobject.h',
'cplusplus.pxd',
diff --git a/src/sage/features/ffmpeg.py b/src/sage/features/ffmpeg.py
index 8214e4d6ff3..c33e36062a1 100644
--- a/src/sage/features/ffmpeg.py
+++ b/src/sage/features/ffmpeg.py
@@ -76,19 +76,19 @@ def is_functional(self):
# The `-nostdin` is needed to avoid the command to hang, see
# https://stackoverflow.com/questions/16523746/ffmpeg-hangs-when-run-in-background
commands = []
- for ext in ['.avi', '.flv', '.gif', '.mkv', '.mov', #'.mpg',
- '.mp4', '.ogg', '.ogv', '.webm', '.wmv']:
+ for ext in ['.avi', '.flv', '.gif', '.mkv', '.mov',
+ '.mp4', '.ogg', '.ogv', '.webm', '.wmv']:
cmd = ['ffmpeg', '-nostdin', '-y', '-f', 'image2', '-r', '5',
- '-i', filename_png, '-pix_fmt', 'rgb24', '-loop', '0',
- filename + ext]
+ '-i', filename_png, '-pix_fmt', 'rgb24', '-loop', '0',
+ filename + ext]
commands.append(cmd)
for ext in ['.avi', '.flv', '.gif', '.mkv', '.mov', '.mpg',
- '.mp4', '.ogg', '.ogv', '.webm', '.wmv']:
+ '.mp4', '.ogg', '.ogv', '.webm', '.wmv']:
cmd = ['ffmpeg', '-nostdin', '-y', '-f', 'image2', '-i',
- filename_png, filename + ext]
+ filename_png, filename + ext]
commands.append(cmd)
# Running the commands and reporting any issue encountered
diff --git a/src/sage/functions/meson.build b/src/sage/functions/meson.build
index c2a77f0e238..85b7b4afa49 100644
--- a/src/sage/functions/meson.build
+++ b/src/sage/functions/meson.build
@@ -1,4 +1,5 @@
py.install_sources(
+ '__init__.py',
'airy.py',
'all.py',
'bessel.py',
diff --git a/src/sage/games/meson.build b/src/sage/games/meson.build
index d0776c0c71a..8852b13d9cf 100644
--- a/src/sage/games/meson.build
+++ b/src/sage/games/meson.build
@@ -1,4 +1,5 @@
py.install_sources(
+ '__init__.py',
'all.py',
'hexad.py',
'quantumino.py',
diff --git a/src/sage/geometry/hyperbolic_space/hyperbolic_isometry.py b/src/sage/geometry/hyperbolic_space/hyperbolic_isometry.py
index 2dd20676215..9fe8f9e5a67 100644
--- a/src/sage/geometry/hyperbolic_space/hyperbolic_isometry.py
+++ b/src/sage/geometry/hyperbolic_space/hyperbolic_isometry.py
@@ -188,9 +188,9 @@ def __eq__(self, other):
return False
test_matrix = bool((self.matrix() - other.matrix()).norm() < EPSILON)
if self.domain().is_isometry_group_projective():
- A,B = self.matrix(), other.matrix() # Rename for simplicity
+ A, B = self.matrix(), other.matrix() # Rename for simplicity
m = self.matrix().ncols()
- A = A / sqrt(A.det(), m) # Normalized to have determinant 1
+ A = A / sqrt(A.det(), m) # Normalized to have determinant 1
B = B / sqrt(B.det(), m)
test_matrix = ((A - B).norm() < EPSILON
or (A + B).norm() < EPSILON)
@@ -636,7 +636,7 @@ class HyperbolicIsometryUHP(HyperbolicIsometry):
[1 0]
[0 1]
"""
- def _call_(self, p): #UHP
+ def _call_(self, p): # UHP
r"""
Return image of ``p`` under the action of ``self``.
@@ -656,7 +656,7 @@ def _call_(self, p): #UHP
coords = coords.conjugate()
return self.codomain().get_point(moebius_transform(self._matrix, coords))
- def preserves_orientation(self): #UHP
+ def preserves_orientation(self): # UHP
r"""
Return ``True`` if ``self`` is orientation-preserving and ``False``
otherwise.
@@ -673,7 +673,7 @@ def preserves_orientation(self): #UHP
"""
return bool(self._matrix.det() > 0)
- def classification(self): #UHP
+ def classification(self): # UHP
r"""
Classify the hyperbolic isometry as elliptic, parabolic, or
hyperbolic.
@@ -725,7 +725,7 @@ def classification(self): #UHP
return 'reflection'
return 'orientation-reversing hyperbolic'
- def translation_length(self): #UHP
+ def translation_length(self): # UHP
r"""
For hyperbolic elements, return the translation length;
otherwise, raise a :exc:`ValueError`.
@@ -800,7 +800,7 @@ def fixed_point_set(self): # UHP
d = sqrt(tau - 4)
return [pt((M[0,0] - M[1,1] + sign(M[1,0])*d) / (2*M[1,0]))]
elif M_cls == 'hyperbolic':
- if M[1,0] != 0: #if the isometry doesn't fix infinity
+ if M[1,0] != 0: # if the isometry does not fix infinity
d = sqrt(tau - 4)
p_1 = (M[0,0] - M[1,1]+d) / (2*M[1,0])
p_2 = (M[0,0] - M[1,1]-d) / (2*M[1,0])
@@ -898,7 +898,7 @@ class HyperbolicIsometryPD(HyperbolicIsometry):
[1 0]
[0 1]
"""
- def _call_(self, p): #PD
+ def _call_(self, p): # PD
r"""
Return image of ``p`` under the action of ``self``.
@@ -917,7 +917,7 @@ def _call_(self, p): #PD
_image = moebius_transform(self._matrix, coords)
return self.codomain().get_point(_image)
- def __mul__(self, other): #PD
+ def __mul__(self, other): # PD
r"""
Return image of ``p`` under the action of ``self``.
@@ -935,7 +935,7 @@ def __mul__(self, other): #PD
return M.to_model('PD')
return super().__mul__(other)
- def __pow__(self, n): #PD
+ def __pow__(self, n): # PD
r"""
EXAMPLES::
@@ -948,7 +948,7 @@ def __pow__(self, n): #PD
"""
return (self._cached_isometry**n).to_model('PD')
- def preserves_orientation(self): #PD
+ def preserves_orientation(self): # PD
"""
Return ``True`` if ``self`` preserves orientation and ``False``
otherwise.
@@ -964,7 +964,7 @@ def preserves_orientation(self): #PD
return bool(self._matrix.det() > 0) and HyperbolicIsometryPD._orientation_preserving(self._matrix)
@staticmethod
- def _orientation_preserving(A): #PD
+ def _orientation_preserving(A): # PD
r"""
For a matrix ``A`` of a PD isometry, determine if it preserves
orientation.
@@ -1001,7 +1001,7 @@ class HyperbolicIsometryKM(HyperbolicIsometry):
[0 1 0]
[0 0 1]
"""
- def _call_(self, p): #KM
+ def _call_(self, p): # KM
r"""
Return image of ``p`` under the action of ``self``.
@@ -1019,7 +1019,7 @@ def _call_(self, p): #KM
return self.codomain().get_point(v[0:2] / v[2])
#####################################################################
-## Helper functions
+# Helper functions
def moebius_transform(A, z):
diff --git a/src/sage/geometry/meson.build b/src/sage/geometry/meson.build
index 8906b859dde..3b48404564d 100644
--- a/src/sage/geometry/meson.build
+++ b/src/sage/geometry/meson.build
@@ -1,4 +1,5 @@
py.install_sources(
+ '__init__.py',
'all.py',
'cone.py',
'cone_catalog.py',
diff --git a/src/sage/geometry/polyhedron/combinatorial_polyhedron/meson.build b/src/sage/geometry/polyhedron/combinatorial_polyhedron/meson.build
index 4b4ea8df4e7..a279309fc13 100644
--- a/src/sage/geometry/polyhedron/combinatorial_polyhedron/meson.build
+++ b/src/sage/geometry/polyhedron/combinatorial_polyhedron/meson.build
@@ -1,4 +1,5 @@
py.install_sources(
+ '__init__.py',
'all.py',
'base.pxd',
'combinatorial_face.pxd',
diff --git a/src/sage/geometry/polyhedron/meson.build b/src/sage/geometry/polyhedron/meson.build
index 3b07bbdd9a5..db589c39385 100644
--- a/src/sage/geometry/polyhedron/meson.build
+++ b/src/sage/geometry/polyhedron/meson.build
@@ -1,4 +1,5 @@
py.install_sources(
+ '__init__.py',
'all.py',
'backend_cdd.py',
'backend_cdd_rdf.py',
diff --git a/src/sage/geometry/polyhedron/modules/formal_polyhedra_module.py b/src/sage/geometry/polyhedron/modules/formal_polyhedra_module.py
index d7ef932a4cf..91101f120fc 100644
--- a/src/sage/geometry/polyhedron/modules/formal_polyhedra_module.py
+++ b/src/sage/geometry/polyhedron/modules/formal_polyhedra_module.py
@@ -82,7 +82,7 @@ def __classcall__(cls, base_ring, dimension, basis, category=None):
"""
if isinstance(basis, list):
basis = tuple(basis)
- if isinstance(basis, tuple): #To make sure it only check for finite input
+ if isinstance(basis, tuple): # To make sure it only checks for finite input
from sage.geometry.polyhedron.base import Polyhedron_base
for P in basis:
if not isinstance(P, Polyhedron_base):
diff --git a/src/sage/geometry/triangulation/meson.build b/src/sage/geometry/triangulation/meson.build
index dec407d83d5..e8361a9da09 100644
--- a/src/sage/geometry/triangulation/meson.build
+++ b/src/sage/geometry/triangulation/meson.build
@@ -1,4 +1,5 @@
py.install_sources(
+ '__init__.py',
'all.py',
'data.pxd',
'element.py',
diff --git a/src/sage/graphs/base/meson.build b/src/sage/graphs/base/meson.build
index 92e205ceb81..badf69f0478 100644
--- a/src/sage/graphs/base/meson.build
+++ b/src/sage/graphs/base/meson.build
@@ -1,4 +1,5 @@
py.install_sources(
+ '__init__.py',
'all.py',
'boost_graph.pxd',
'c_graph.pxd',
diff --git a/src/sage/graphs/centrality.pyx b/src/sage/graphs/centrality.pyx
old mode 100755
new mode 100644
diff --git a/src/sage/graphs/chrompoly.pyx b/src/sage/graphs/chrompoly.pyx
index 17a9837041b..d0ca79b60b5 100644
--- a/src/sage/graphs/chrompoly.pyx
+++ b/src/sage/graphs/chrompoly.pyx
@@ -31,7 +31,7 @@ from memory_allocator cimport MemoryAllocator
from sage.libs.gmp.mpz cimport *
from sage.rings.integer_ring import ZZ
from sage.rings.integer cimport Integer
-from sage.rings.ring cimport Ring
+from sage.rings.ring cimport CommutativeRing
from sage.rings.polynomial.polynomial_integer_dense_flint cimport Polynomial_integer_dense_flint
from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing
@@ -436,7 +436,7 @@ def chromatic_polynomial_with_cache(G, cache=None):
...
TypeError: parameter cache must be a dictionary or None
"""
- cdef Ring R = PolynomialRing(ZZ, "x", implementation="FLINT")
+ cdef CommutativeRing R = PolynomialRing(ZZ, "x", implementation="FLINT")
cdef Polynomial_integer_dense_flint one = R.one()
cdef Polynomial_integer_dense_flint zero = R.zero()
cdef Polynomial_integer_dense_flint x = R.gen()
diff --git a/src/sage/graphs/generators/meson.build b/src/sage/graphs/generators/meson.build
index 44542f2631e..c98c2647c25 100644
--- a/src/sage/graphs/generators/meson.build
+++ b/src/sage/graphs/generators/meson.build
@@ -1,4 +1,5 @@
py.install_sources(
+ '__init__.py',
'all.py',
'basic.py',
'chessboard.py',
diff --git a/src/sage/graphs/graph_decompositions/meson.build b/src/sage/graphs/graph_decompositions/meson.build
index 041f8824fbd..913c682ebac 100644
--- a/src/sage/graphs/graph_decompositions/meson.build
+++ b/src/sage/graphs/graph_decompositions/meson.build
@@ -8,6 +8,7 @@ endif
rw = cc.find_library('rw')
py.install_sources(
+ '__init__.py',
'all.py',
'all__sagemath_tdlib.py',
'fast_digraph.pxd',
diff --git a/src/sage/graphs/meson.build b/src/sage/graphs/meson.build
index 28fbcaf24ef..842501734e5 100644
--- a/src/sage/graphs/meson.build
+++ b/src/sage/graphs/meson.build
@@ -11,6 +11,7 @@ cliquer = cc.find_library('cliquer')
planarity = cc.find_library('planarity')
py.install_sources(
+ '__init__.py',
'all.py',
'all__sagemath_bliss.py',
'all__sagemath_mcqd.py',
diff --git a/src/sage/graphs/strongly_regular_db.pyx b/src/sage/graphs/strongly_regular_db.pyx
index 72db0131c59..2f6f8339aa5 100644
--- a/src/sage/graphs/strongly_regular_db.pyx
+++ b/src/sage/graphs/strongly_regular_db.pyx
@@ -1068,25 +1068,25 @@ def is_polhill(int v, int k, int l, int mu):
# We now define the P_{i,j}. see section 6.
P = {}
- P[0,1] = list(range((-1) + 1 , 2**(s-2)+1))
- P[1,1] = list(range((-1) + 2**(s-2)+2 , 2**(s-1)+1))
- P[2,1] = list(range((-1) + 2**(s-1)+2 , 2**(s-1)+2**(s-2)+1))
- P[3,1] = list(range((-1) + 2**(s-1)+2**(s-2)+2, 2**(s)+1))
-
- P[0,2] = list(range((-1) + 2**(s-2)+2 , 2**(s-1)+2))
- P[1,2] = list(range((-1) + 2**(s-1)+3 , 2**(s-1)+2**(s-2)+2))
- P[2,2] = list(range((-1) + 2**(s-1)+2**(s-2)+3, 2**(s)+1)) + [0]
- P[3,2] = list(range((-1) + 2 , 2**(s-2)+1))
-
- P[0,3] = list(range((-1) + 2**(s-1)+3 , 2**(s-1)+2**(s-2)+3))
- P[1,3] = list(range((-1) + 2**(s-1)+2**(s-2)+4, 2**(s)+1)) + [0,1]
- P[2,3] = list(range((-1) + 3 , 2**(s-2)+2))
- P[3,3] = list(range((-1) + 2**(s-2)+3 , 2**(s-1)+2))
-
- P[0,4] = list(range((-1) + 2**(s-1)+2**(s-2)+4, 2**(s)+1))
- P[1,4] = list(range((-1) + 3 , 2**(s-2)+1)) + [2**(s-1)+1,2**(s-1)+2**(s-2)+2]
- P[2,4] = list(range((-1) + 2**(s-2)+3 , 2**(s-1)+1)) + [2**(s-1)+2**(s-2)+1,1]
- P[3,4] = list(range((-1) + 2**(s-1)+3 , 2**(s-1)+2**(s-2)+1)) + [2**(s-2)+1,0]
+ P[0, 1] = list(range((-1) + 1, 2**(s-2)+1))
+ P[1, 1] = list(range((-1) + 2**(s-2)+2, 2**(s-1)+1))
+ P[2, 1] = list(range((-1) + 2**(s-1)+2, 2**(s-1)+2**(s-2)+1))
+ P[3, 1] = list(range((-1) + 2**(s-1)+2**(s-2)+2, 2**(s)+1))
+
+ P[0, 2] = list(range((-1) + 2**(s-2)+2, 2**(s-1)+2))
+ P[1, 2] = list(range((-1) + 2**(s-1)+3, 2**(s-1)+2**(s-2)+2))
+ P[2, 2] = list(range((-1) + 2**(s-1)+2**(s-2)+3, 2**(s)+1)) + [0]
+ P[3, 2] = list(range((-1) + 2, 2**(s-2)+1))
+
+ P[0, 3] = list(range((-1) + 2**(s-1)+3, 2**(s-1)+2**(s-2)+3))
+ P[1, 3] = list(range((-1) + 2**(s-1)+2**(s-2)+4, 2**(s)+1)) + [0,1]
+ P[2, 3] = list(range((-1) + 3, 2**(s-2)+2))
+ P[3, 3] = list(range((-1) + 2**(s-2)+3, 2**(s-1)+2))
+
+ P[0, 4] = list(range((-1) + 2**(s-1)+2**(s-2)+4, 2**(s)+1))
+ P[1, 4] = list(range((-1) + 3, 2**(s-2)+1)) + [2**(s-1)+1,2**(s-1)+2**(s-2)+2]
+ P[2, 4] = list(range((-1) + 2**(s-2)+3, 2**(s-1)+1)) + [2**(s-1)+2**(s-2)+1,1]
+ P[3, 4] = list(range((-1) + 2**(s-1)+3, 2**(s-1)+2**(s-2)+1)) + [2**(s-2)+1,0]
R = {x: copy(P[x]) for x in P}
@@ -1100,10 +1100,10 @@ def is_polhill(int v, int k, int l, int mu):
# We now define the R_{i,j}. see *end* of section 6.
- R[0,3] = list(range((-1) + 2**(s-1)+3 , 2**(s-1)+2**(s-2)+2))
- R[1,3] = list(range((-1) + 2**(s-1)+2**(s-2)+4, 2**(s)+1)) + [0,1,2**(s-1)+2**(s-2)+2]
- R[0,4] = list(range((-1) + 2**(s-1)+2**(s-2)+4, 2**(s)+1)) + [2**(s-1)+2**(s-2)+2]
- R[1,4] = list(range((-1) + 3 , 2**(s-2)+1)) + [2**(s-1)+1]
+ R[0, 3] = list(range((-1) + 2**(s-1)+3, 2**(s-1)+2**(s-2)+2))
+ R[1, 3] = list(range((-1) + 2**(s-1)+2**(s-2)+4, 2**(s)+1)) + [0,1,2**(s-1)+2**(s-2)+2]
+ R[0, 4] = list(range((-1) + 2**(s-1)+2**(s-2)+4, 2**(s)+1)) + [2**(s-1)+2**(s-2)+2]
+ R[1, 4] = list(range((-1) + 3, 2**(s-2)+1)) + [2**(s-1)+1]
for x in R:
R[x] = [K[i] for i in R[x]]
diff --git a/src/sage/groups/matrix_gps/meson.build b/src/sage/groups/matrix_gps/meson.build
index 30b8e2379c0..77c70adf7fa 100644
--- a/src/sage/groups/matrix_gps/meson.build
+++ b/src/sage/groups/matrix_gps/meson.build
@@ -1,4 +1,5 @@
py.install_sources(
+ '__init__.py',
'all.py',
'binary_dihedral.py',
'catalog.py',
diff --git a/src/sage/groups/meson.build b/src/sage/groups/meson.build
index a1876172c4d..3c5f20a1214 100644
--- a/src/sage/groups/meson.build
+++ b/src/sage/groups/meson.build
@@ -1,4 +1,5 @@
py.install_sources(
+ '__init__.py',
'all.py',
'artin.py',
'braid.py',
diff --git a/src/sage/groups/perm_gps/meson.build b/src/sage/groups/perm_gps/meson.build
index e986fcd964a..6ad30d99fe2 100644
--- a/src/sage/groups/perm_gps/meson.build
+++ b/src/sage/groups/perm_gps/meson.build
@@ -1,4 +1,5 @@
py.install_sources(
+ '__init__.py',
'all.py',
'constructor.py',
'cubegroup.py',
diff --git a/src/sage/groups/perm_gps/partn_ref/meson.build b/src/sage/groups/perm_gps/partn_ref/meson.build
index 092b0d0b2c8..933d72d2729 100644
--- a/src/sage/groups/perm_gps/partn_ref/meson.build
+++ b/src/sage/groups/perm_gps/partn_ref/meson.build
@@ -1,4 +1,5 @@
py.install_sources(
+ '__init__.py',
'all.py',
'automorphism_group_canonical_label.pxd',
'canonical_augmentation.pxd',
diff --git a/src/sage/groups/perm_gps/partn_ref2/meson.build b/src/sage/groups/perm_gps/partn_ref2/meson.build
index ef97195574e..69b9bee042d 100644
--- a/src/sage/groups/perm_gps/partn_ref2/meson.build
+++ b/src/sage/groups/perm_gps/partn_ref2/meson.build
@@ -1,4 +1,5 @@
py.install_sources(
+ '__init__.py',
'all.py',
'refinement_generic.pxd',
subdir: 'sage/groups/perm_gps/partn_ref2',
diff --git a/src/sage/groups/semimonomial_transformations/meson.build b/src/sage/groups/semimonomial_transformations/meson.build
index 402cb5244e5..f7958976271 100644
--- a/src/sage/groups/semimonomial_transformations/meson.build
+++ b/src/sage/groups/semimonomial_transformations/meson.build
@@ -1,4 +1,5 @@
py.install_sources(
+ '__init__.py',
'all.py',
'semimonomial_transformation.pxd',
'semimonomial_transformation_group.py',
diff --git a/src/sage/interacts/meson.build b/src/sage/interacts/meson.build
index 4889c06f9fa..b0542f38853 100644
--- a/src/sage/interacts/meson.build
+++ b/src/sage/interacts/meson.build
@@ -1,4 +1,5 @@
py.install_sources(
+ '__init__.py',
'algebra.py',
'all.py',
'calculus.py',
diff --git a/src/sage/interfaces/meson.build b/src/sage/interfaces/meson.build
index 4a12245d532..aee6b8493d0 100644
--- a/src/sage/interfaces/meson.build
+++ b/src/sage/interfaces/meson.build
@@ -1,4 +1,5 @@
py.install_sources(
+ '__init__.py',
'abc.py',
'all.py',
'all__sagemath_polyhedra.py',
diff --git a/src/sage/interfaces/singular.py b/src/sage/interfaces/singular.py
index d02ae43149f..d110c17bf16 100644
--- a/src/sage/interfaces/singular.py
+++ b/src/sage/interfaces/singular.py
@@ -1401,7 +1401,7 @@ def _repr_(self):
# this is our cue that singular uses `rp` instead of `ip`
if singular_name_mapping['invlex'] == 'rp' and 'doctest' in str(get_display_manager()):
s = re.sub('^(// .*block.* : ordering )rp$', '\\1ip',
- s, 0, re.MULTILINE)
+ s, flags=re.MULTILINE)
return s
def __copy__(self):
@@ -1785,7 +1785,7 @@ def sage_poly(self, R=None, kcache=None):
# TODO: Refactor imports to move this to the top
from sage.rings.polynomial.multi_polynomial_ring import MPolynomialRing_polydict
from sage.rings.polynomial.multi_polynomial_libsingular import MPolynomialRing_libsingular
- from sage.rings.polynomial.polynomial_ring import PolynomialRing_general
+ from sage.rings.polynomial.polynomial_ring import PolynomialRing_generic
from sage.rings.polynomial.polydict import ETuple
from sage.rings.polynomial.polynomial_singular_interface import can_convert_to_singular
from sage.rings.quotient_ring import QuotientRing_generic
@@ -1876,7 +1876,7 @@ def sage_poly(self, R=None, kcache=None):
return R(sage_repr)
- elif isinstance(R, PolynomialRing_general) and (ring_is_fine or can_convert_to_singular(R)):
+ elif isinstance(R, PolynomialRing_generic) and (ring_is_fine or can_convert_to_singular(R)):
sage_repr = [0] * int(self.deg() + 1)
diff --git a/src/sage/lfunctions/meson.build b/src/sage/lfunctions/meson.build
index cf0ffe05e17..24e2f156f5e 100644
--- a/src/sage/lfunctions/meson.build
+++ b/src/sage/lfunctions/meson.build
@@ -1,4 +1,5 @@
py.install_sources(
+ '__init__.py',
'all.py',
'dokchitser.py',
'lcalc.py',
diff --git a/src/sage/libs/gap/meson.build b/src/sage/libs/gap/meson.build
index 2302a169cb2..def07898f4c 100644
--- a/src/sage/libs/gap/meson.build
+++ b/src/sage/libs/gap/meson.build
@@ -1,4 +1,5 @@
py.install_sources(
+ '__init__.py',
'all.py',
'all_documented_functions.py',
'assigned_names.py',
diff --git a/src/sage/libs/meson.build b/src/sage/libs/meson.build
index 2e28ef8ff79..34b26b09ff1 100644
--- a/src/sage/libs/meson.build
+++ b/src/sage/libs/meson.build
@@ -6,6 +6,7 @@ gc = cc.find_library('gc')
homfly = cc.find_library('homfly', has_headers: ['homfly.h'])
py.install_sources(
+ '__init__.py',
'all.py',
'all__sagemath_coxeter3.py',
'all__sagemath_meataxe.py',
diff --git a/src/sage/libs/singular/function.pyx b/src/sage/libs/singular/function.pyx
index 7bf2afafbe8..766eb8826e1 100644
--- a/src/sage/libs/singular/function.pyx
+++ b/src/sage/libs/singular/function.pyx
@@ -97,7 +97,7 @@ from sage.rings.polynomial.multi_polynomial_sequence import PolynomialSequence_g
from sage.libs.singular.decl cimport *
from sage.libs.singular.option import opt_ctx
from sage.libs.singular.polynomial cimport singular_vector_maximal_component
-from sage.libs.singular.singular cimport sa2si, si2sa, si2sa_intvec, si2sa_bigintvec
+from sage.libs.singular.singular cimport sa2si, si2sa, si2sa_intvec, si2sa_bigintvec, start_catch_error, check_error
from sage.libs.singular.singular import error_messages
from sage.interfaces.singular import get_docstring
@@ -1450,10 +1450,8 @@ EXAMPLES::
cdef inline call_function(SingularFunction self, tuple args, object R, bint signal_handler=True, attributes=None):
global currRingHdl
- global errorreported
global currentVoice
global myynest
- global error_messages
cdef ring *si_ring
if isinstance(R, MPolynomialRing_libsingular):
@@ -1474,29 +1472,28 @@ cdef inline call_function(SingularFunction self, tuple args, object R, bint sign
currentVoice = NULL
myynest = 0
- errorreported = 0
-
- while error_messages:
- error_messages.pop()
+ start_catch_error()
with opt_ctx: # we are preserving the global options state here
if signal_handler:
- sig_on()
- _res = self.call_handler.handle_call(argument_list, si_ring)
- sig_off()
+ try:
+ sig_on()
+ _res = self.call_handler.handle_call(argument_list, si_ring)
+ sig_off()
+ finally:
+ s = check_error()
else:
_res = self.call_handler.handle_call(argument_list, si_ring)
+ s = check_error()
- if myynest:
- myynest = 0
+ myynest = 0
if currentVoice:
currentVoice = NULL
- if errorreported:
- errorreported = 0
+ if s:
raise RuntimeError("error in Singular function call %r:\n%s" %
- (self._name, "\n".join(error_messages)))
+ (self._name, "\n".join(s)))
res = argument_list.to_python(_res)
diff --git a/src/sage/libs/singular/ring.pyx b/src/sage/libs/singular/ring.pyx
index f770cc483a5..fa7343f8dca 100644
--- a/src/sage/libs/singular/ring.pyx
+++ b/src/sage/libs/singular/ring.pyx
@@ -19,7 +19,7 @@ AUTHORS:
from sage.cpython.string cimport str_to_bytes, bytes_to_str
from sage.libs.gmp.types cimport __mpz_struct
-from sage.libs.gmp.mpz cimport mpz_init_set_ui
+from sage.libs.gmp.mpz cimport mpz_init_set
from sage.libs.singular.decl cimport ring, currRing
from sage.libs.singular.decl cimport rChangeCurrRing, rComplete, rDelete, idInit
@@ -31,6 +31,7 @@ from sage.libs.singular.decl cimport n_coeffType
from sage.libs.singular.decl cimport rDefault, GFInfo, ZnmInfo, nInitChar, AlgExtInfo, TransExtInfo
+from sage.rings.integer cimport Integer
from sage.rings.integer_ring cimport IntegerRing_class
from sage.rings.integer_ring import ZZ
import sage.rings.abc
@@ -80,7 +81,7 @@ if bytes_to_str(rSimpleOrdStr(ringorder_ip)) == "rp":
#############################################################################
cdef ring *singular_ring_new(base_ring, n, names, term_order) except NULL:
- """
+ r"""
Create a new Singular ring over the ``base_ring`` in ``n``
variables with the names ``names`` and the term order
``term_order``.
@@ -159,17 +160,136 @@ cdef ring *singular_ring_new(base_ring, n, names, term_order) except NULL:
sage: R. = F[]
sage: from sage.libs.singular.function import singular_function
sage: sing_print = singular_function('print')
- sage: sing_print(R)
- 'polynomial ring, over a field, global ordering\n// coefficients: ZZ/7(a, b)\n// number of vars : 3\n// block 1 : ordering dp\n// : names x y z\n// block 2 : ordering C'
+ sage: print(sing_print(R))
+ polynomial ring, over a field, global ordering
+ // coefficients: ZZ/7(a, b)
+ // number of vars : 3
+ // block 1 : ordering dp
+ // : names x y z
+ // block 2 : ordering C
::
sage: F = PolynomialRing(QQ, 's,t').fraction_field()
sage: R. = F[]
sage: from sage.libs.singular.function import singular_function
- sage: sing_print = singular_function('print')
- sage: sing_print(R)
- 'polynomial ring, over a field, global ordering\n// coefficients: QQ(s, t)\n// number of vars : 3\n// block 1 : ordering dp\n// : names x y z\n// block 2 : ordering C'
+ sage: print(sing_print(R))
+ polynomial ring, over a field, global ordering
+ // coefficients: QQ(s, t)
+ // number of vars : 3
+ // block 1 : ordering dp
+ // : names x y z
+ // block 2 : ordering C
+
+ Small primes::
+
+ sage: R = PolynomialRing(GF(2), ("a", "b"), implementation="singular"); print(sing_print(R))
+ polynomial ring, over a field, global ordering
+ // coefficients: ZZ/2
+ // number of vars : 2
+ // block 1 : ordering dp
+ // : names a b
+ // block 2 : ordering C
+ sage: R = PolynomialRing(GF(3), ("a", "b"), implementation="singular"); print(sing_print(R))
+ polynomial ring, over a field, global ordering
+ // coefficients: ZZ/3
+ // number of vars : 2
+ // block 1 : ordering dp
+ // : names a b
+ // block 2 : ordering C
+ sage: R = PolynomialRing(GF(1000000007), ("a", "b"), implementation="singular"); print(sing_print(R))
+ polynomial ring, over a field, global ordering
+ // coefficients: ZZ/1000000007
+ // number of vars : 2
+ // block 1 : ordering dp
+ // : names a b
+ // block 2 : ordering C
+
+ When ``Zmod`` is used, use a different Singular type
+ (note that the print is wrong, the field in fact doesn't have zero-divisors)::
+
+ sage: R = PolynomialRing(Zmod(2), ("a", "b"), implementation="singular"); print(sing_print(R))
+ polynomial ring, over a ring (with zero-divisors), global ordering
+ // coefficients: ZZ/(2)
+ // number of vars : 2
+ // block 1 : ordering dp
+ // : names a b
+ // block 2 : ordering C
+ sage: R = PolynomialRing(Zmod(3), ("a", "b"), implementation="singular"); print(sing_print(R))
+ polynomial ring, over a ring (with zero-divisors), global ordering
+ // coefficients: ZZ/(3)
+ // number of vars : 2
+ // block 1 : ordering dp
+ // : names a b
+ // block 2 : ordering C
+
+ Large prime (note that the print is wrong, the field in fact doesn't have zero-divisors)::
+
+ sage: R = PolynomialRing(GF(2^128+51), ("a", "b"), implementation="singular"); print(sing_print(R))
+ polynomial ring, over a ring (with zero-divisors), global ordering
+ // coefficients: ZZ/bigint(340282366920938463463374607431768211507)
+ // number of vars : 2
+ // block 1 : ordering dp
+ // : names a b
+ // block 2 : ordering C
+
+ Finite field with large degree (note that if stack size is too small and the exponent is too large
+ a stack overflow may happen inside libsingular)::
+
+ sage: R = PolynomialRing(GF(2^160), ("a", "b"), implementation="singular"); print(sing_print(R))
+ polynomial ring, over a field, global ordering
+ // coefficients: ZZ/2[z160]/(z160^160+z160^159+z160^155+z160^154+z160^153+z160^152+z160^151+z160^149+z160^148+z160^147+z160^146+z160^145+z160^144+z160^143+z160^141+z160^139+z160^137+z160^131+z160^129+z160^128+z160^127+z160^126+z160^123+z160^122+z160^121+z160^117+z160^116+z160^115+z160^113+z160^111+z160^110+z160^108+z160^106+z160^102+z160^100+z160^99+z160^97+z160^96+z160^95+z160^94+z160^93+z160^92+z160^91+z160^87+z160^86+z160^82+z160^80+z160^79+z160^78+z160^74+z160^73+z160^72+z160^71+z160^70+z160^67+z160^66+z160^65+z160^62+z160^59+z160^58+z160^57+z160^55+z160^54+z160^53+z160^52+z160^51+z160^49+z160^47+z160^44+z160^40+z160^35+z160^32+z160^30+z160^28+z160^27+z160^26+z160^24+z160^23+z160^21+z160^20+z160^18+z160^16+z160^11+z160^10+z160^8+z160^7+1)
+ // number of vars : 2
+ // block 1 : ordering dp
+ // : names a b
+ // block 2 : ordering C
+
+ Integer modulo small power of 2::
+
+ sage: R = PolynomialRing(Zmod(2^32), ("a", "b"), implementation="singular"); print(sing_print(R))
+ polynomial ring, over a ring (with zero-divisors), global ordering
+ // coefficients: ZZ/(2^32)
+ // number of vars : 2
+ // block 1 : ordering dp
+ // : names a b
+ // block 2 : ordering C
+
+ Integer modulo large power of 2::
+
+ sage: R = PolynomialRing(Zmod(2^1000), ("a", "b"), implementation="singular"); print(sing_print(R))
+ polynomial ring, over a ring (with zero-divisors), global ordering
+ // coefficients: ZZ/(bigint(2)^1000)
+ // number of vars : 2
+ // block 1 : ordering dp
+ // : names a b
+ // block 2 : ordering C
+
+ Integer modulo large power of odd prime::
+
+ sage: R = PolynomialRing(Zmod(3^300), ("a", "b"), implementation="singular"); print(sing_print(R))
+ polynomial ring, over a ring (with zero-divisors), global ordering
+ // coefficients: ZZ/(bigint(3)^300)
+ // number of vars : 2
+ // block 1 : ordering dp
+ // : names a b
+ // block 2 : ordering C
+
+ Integer modulo non-prime::
+
+ sage: R = PolynomialRing(Zmod(15^20), ("a", "b"), implementation="singular"); print(sing_print(R))
+ polynomial ring, over a ring (with zero-divisors), global ordering
+ // coefficients: ZZ/bigint(332525673007965087890625)
+ // number of vars : 2
+ // block 1 : ordering dp
+ // : names a b
+ // block 2 : ordering C
+
+ Non-prime finite field with large characteristic (not supported, see :issue:`33319`)::
+
+ sage: PolynomialRing(GF((2^31+11)^2), ("a", "b"), implementation="singular")
+ Traceback (most recent call last):
+ ...
+ TypeError: characteristic must be <= 2147483647.
"""
cdef long cexponent
cdef GFInfo* _param
@@ -182,7 +302,7 @@ cdef ring *singular_ring_new(base_ring, n, names, term_order) except NULL:
cdef int offset
cdef int nvars
cdef int characteristic
- cdef int modbase
+ cdef Integer ch, modbase
cdef int ringorder_column_pos
cdef int ringorder_column_asc
@@ -377,39 +497,57 @@ cdef ring *singular_ring_new(base_ring, n, names, term_order) except NULL:
_cf = nInitChar( n_Z, NULL) # integer coefficient ring
_ring = rDefault (_cf, nvars, _names, nblcks, _order, _block0, _block1, _wvhdl)
- elif (isinstance(base_ring, FiniteField_generic) and base_ring.is_prime_field()):
- if base_ring.characteristic() <= 2147483647:
+ elif isinstance(base_ring, sage.rings.abc.IntegerModRing):
+
+ ch = base_ring.characteristic()
+ if ch < 2:
+ raise NotImplementedError(f"polynomials over {base_ring} are not supported in Singular")
+
+ isprime = ch.is_prime()
+
+ if isprime and ch <= 2147483647 and isinstance(base_ring, FiniteField_generic):
+ # don't use this branch for e.g. Zmod(5)
characteristic = base_ring.characteristic()
+
+ # example for simpler ring creation interface without monomial orderings:
+ #_ring = rDefault(characteristic, nvars, _names)
+
+ _ring = rDefault(characteristic, nvars, _names, nblcks, _order, _block0, _block1, _wvhdl)
+
else:
- raise TypeError("Characteristic p must be <= 2147483647.")
+ modbase, cexponent = ch.perfect_power()
- # example for simpler ring creation interface without monomial orderings:
- #_ring = rDefault(characteristic, nvars, _names)
+ if modbase == 2 and cexponent > 1:
+ _cf = nInitChar(n_Z2m, cexponent)
- _ring = rDefault(characteristic, nvars, _names, nblcks, _order, _block0, _block1, _wvhdl)
+ elif modbase.is_prime() and cexponent > 1:
+ _info.base = <__mpz_struct *>omAlloc(sizeof(__mpz_struct))
+ mpz_init_set(_info.base, modbase.value)
+ _info.exp = cexponent
+ _cf = nInitChar(n_Znm, &_info)
+
+ else:
+ _info.base = <__mpz_struct *>omAlloc(sizeof(__mpz_struct))
+ mpz_init_set(_info.base, ch.value)
+ _info.exp = 1
+ _cf = nInitChar(n_Zn, &_info)
+ _ring = rDefault(_cf, nvars, _names, nblcks, _order, _block0, _block1, _wvhdl)
elif isinstance(base_ring, FiniteField_generic):
- if base_ring.characteristic() <= 2147483647:
- characteristic = -base_ring.characteristic() # note the negative characteristic
- else:
+ assert not base_ring.is_prime_field() # would have been handled above
+ if base_ring.characteristic() > 2147483647:
raise TypeError("characteristic must be <= 2147483647.")
# TODO: This is lazy, it should only call Singular stuff not PolynomialRing()
k = PolynomialRing(base_ring.prime_subfield(),
- name=base_ring.variable_name(), order='lex', implementation='singular')
+ name=base_ring.variable_name(), order='lex',
+ implementation='singular')
minpoly = base_ring.polynomial()(k.gen())
- ch = base_ring.characteristic()
- F = ch.factor()
- assert(len(F)==1)
-
- modbase = F[0][0]
- cexponent = F[0][1]
-
_ext_names = omAlloc0(sizeof(char*))
_name = str_to_bytes(k._names[0])
_ext_names[0] = omStrDup(_name)
- _cfr = rDefault( modbase, 1, _ext_names )
+ _cfr = rDefault(base_ring.characteristic(), 1, _ext_names)
_cfr.qideal = idInit(1,1)
rComplete(_cfr, 1)
@@ -422,60 +560,6 @@ cdef ring *singular_ring_new(base_ring, n, names, term_order) except NULL:
_ring = rDefault (_cf, nvars, _names, nblcks, _order, _block0, _block1, _wvhdl)
- elif isinstance(base_ring, sage.rings.abc.IntegerModRing):
-
- ch = base_ring.characteristic()
- if ch < 2:
- raise NotImplementedError(f"polynomials over {base_ring} are not supported in Singular")
-
- isprime = ch.is_prime()
-
- if not isprime and ch.is_power_of(2):
- exponent = ch.nbits() -1
- cexponent = exponent
-
- if exponent <= 30:
- ringtype = n_Z2m
- else:
- ringtype = n_Znm
-
- if ringtype == n_Znm:
- F = ch.factor()
-
- modbase = F[0][0]
- cexponent = F[0][1]
-
- _info.base = <__mpz_struct*>omAlloc(sizeof(__mpz_struct))
- mpz_init_set_ui(_info.base, modbase)
- _info.exp = cexponent
- _cf = nInitChar(ringtype, &_info)
- else: # ringtype == n_Z2m
- _cf = nInitChar(ringtype, cexponent)
-
- elif not isprime and ch.is_prime_power() and ch < ZZ(2)**160:
- F = ch.factor()
- assert(len(F)==1)
-
- modbase = F[0][0]
- cexponent = F[0][1]
-
- _info.base = <__mpz_struct*>omAlloc(sizeof(__mpz_struct))
- mpz_init_set_ui(_info.base, modbase)
- _info.exp = cexponent
- _cf = nInitChar( n_Znm, &_info )
-
- else:
- try:
- characteristic = ch
- except OverflowError:
- raise NotImplementedError("Characteristic %d too big." % ch)
-
- _info.base = <__mpz_struct*>omAlloc(sizeof(__mpz_struct))
- mpz_init_set_ui(_info.base, characteristic)
- _info.exp = 1
- _cf = nInitChar( n_Zn, &_info )
- _ring = rDefault(_cf, nvars, _names, nblcks, _order, _block0, _block1, _wvhdl)
-
else:
raise NotImplementedError(f"polynomials over {base_ring} are not supported in Singular")
diff --git a/src/sage/libs/singular/singular.pxd b/src/sage/libs/singular/singular.pxd
index 9d764b51a6f..a0019fe4ede 100644
--- a/src/sage/libs/singular/singular.pxd
+++ b/src/sage/libs/singular/singular.pxd
@@ -55,6 +55,13 @@ cdef number *sa2si_NF(object element, ring *_ring) noexcept
# dispatches to all the above.
cdef number *sa2si(Element elem, ring * _ring) noexcept
+# ==============
+# Error handling
+# ==============
+
+cdef int start_catch_error() except -1
+cdef object check_error()
+
# ==============
# Initialisation
# ==============
diff --git a/src/sage/libs/singular/singular.pyx b/src/sage/libs/singular/singular.pyx
index e2ca2b02e75..813765cff3d 100644
--- a/src/sage/libs/singular/singular.pyx
+++ b/src/sage/libs/singular/singular.pyx
@@ -25,6 +25,7 @@ cdef extern from "limits.h":
long INT_MIN
import os
+from warnings import warn
from libc.stdint cimport int64_t
from sage.libs.singular.decl cimport *
@@ -302,6 +303,9 @@ cdef object si2sa_GFq_generic(number *n, ring *_ring, object base):
cdef object ret
cdef ring *cfRing = _ring.cf.extRing
+ if _ring.cf.type in (n_Zn, n_Znm):
+ return si2sa_ZZmod(n, _ring, base)
+
if _ring.cf.cfIsZero(n,_ring.cf):
return base.zero()
elif _ring.cf.cfIsOne(n,_ring.cf):
@@ -886,7 +890,7 @@ cdef number *sa2si_QQ(Rational r, ring *_ring) noexcept:
- ``r`` -- a sage rational number
- - ``_ ring`` -- a (pointer to) a singular ring, where the resul will live
+ - ``_ ring`` -- a (pointer to) a singular ring, where the result will live
OUTPUT:
@@ -916,7 +920,7 @@ cdef number *sa2si_GFqGivaro(int quo, ring *_ring) noexcept:
- ``quo`` -- sage integer
- - ``_ ring`` -- a (pointer to) a singular ring, where the resul will live
+ - ``_ ring`` -- a (pointer to) a singular ring, where the result will live
OUTPUT:
@@ -984,7 +988,7 @@ cdef number *sa2si_GFqNTLGF2E(FFgf2eE elem, ring *_ring) noexcept:
- ``elem`` -- a sage element of a ntl_gf2e finite field
- - ``_ ring`` -- a (pointer to) a singular ring, where the resul will live
+ - ``_ ring`` -- a (pointer to) a singular ring, where the result will live
OUTPUT:
@@ -1049,7 +1053,7 @@ cdef number *sa2si_GFq_generic(object elem, ring *_ring) noexcept:
- ``elem`` -- a sage element of a generic finite field
- - ``_ ring`` -- a (pointer to) a singular ring, where the resul will live
+ - ``_ ring`` -- a (pointer to) a singular ring, where the result will live
OUTPUT:
@@ -1075,6 +1079,9 @@ cdef number *sa2si_GFq_generic(object elem, ring *_ring) noexcept:
cdef number *coeff
cdef number *apow1
cdef number *apow2
+
+ if _ring.cf.type in (n_Zn, n_Znm):
+ return sa2si_ZZmod(elem, _ring)
elem = elem.polynomial()
if _ring != currRing: rChangeCurrRing(_ring)
@@ -1115,7 +1122,7 @@ cdef number *sa2si_transext_QQ(object elem, ring *_ring) noexcept:
- ``elem`` -- a sage element of a FractionField of polynomials over the rationals
- - ``_ ring`` -- a (pointer to) a singular ring, where the resul will live
+ - ``_ ring`` -- a (pointer to) a singular ring, where the result will live
OUTPUT:
@@ -1265,7 +1272,7 @@ cdef number *sa2si_transext_FF(object elem, ring *_ring) noexcept:
- ``elem`` -- a sage element of a FractionField of polynomials over the rationals
- - ``_ ring`` -- a (pointer to) a singular ring, where the resul will live
+ - ``_ ring`` -- a (pointer to) a singular ring, where the result will live
OUTPUT:
@@ -1365,7 +1372,7 @@ cdef number *sa2si_NF(object elem, ring *_ring) noexcept:
- ``elem`` -- a sage element of a NumberField
- - ``_ ring`` -- a (pointer to) a singular ring, where the resul will live
+ - ``_ ring`` -- a (pointer to) a singular ring, where the result will live
OUTPUT:
@@ -1457,7 +1464,7 @@ cdef number *sa2si_ZZ(Integer d, ring *_ring) noexcept:
- ``elem`` -- a sage Integer
- - ``_ ring`` -- a (pointer to) a singular ring, where the resul will live
+ - ``_ ring`` -- a (pointer to) a singular ring, where the result will live
OUTPUT:
@@ -1488,7 +1495,7 @@ cdef inline number *sa2si_ZZmod(IntegerMod_abstract d, ring *_ring) noexcept:
- ``elem`` -- a sage IntegerMod
- - ``_ ring`` -- a (pointer to) a singular ring, where the resul will live
+ - ``_ ring`` -- a (pointer to) a singular ring, where the result will live
TESTS::
@@ -1512,7 +1519,7 @@ cdef inline number *sa2si_ZZmod(IntegerMod_abstract d, ring *_ring) noexcept:
sage: P. = Integers(2^32)[]
sage: P(2^32-1)
- 4294967295
+ -1
sage: P(3)
3
@@ -1534,6 +1541,9 @@ cdef inline number *sa2si_ZZmod(IntegerMod_abstract d, ring *_ring) noexcept:
cdef nMapFunc nMapFuncPtr = NULL
+ if _ring.cf.type == n_unknown:
+ return n_Init(int(d), _ring.cf)
+
if _ring.cf.type == n_Z2m:
_d = d
return nr2mMapZp(_d, currRing.cf, _ring.cf)
@@ -1577,7 +1587,7 @@ cdef object si2sa(number *n, ring *_ring, object base):
An element of ``base``
"""
- if isinstance(base, FiniteField_prime_modn):
+ if isinstance(base, FiniteField_prime_modn) and _ring.cf.type == n_Zp:
return base(_ring.cf.cfInt(n, _ring.cf))
elif isinstance(base, RationalField):
@@ -1605,8 +1615,6 @@ cdef object si2sa(number *n, ring *_ring, object base):
return si2sa_transext_FF(n, _ring, base)
elif isinstance(base, IntegerModRing_generic):
- if _ring.cf.type == n_unknown:
- return base(_ring.cf.cfInt(n, _ring.cf))
return si2sa_ZZmod(n, _ring, base)
else:
@@ -1628,7 +1636,8 @@ cdef number *sa2si(Element elem, ring * _ring) noexcept:
a (pointer to) a singular number
"""
cdef int i = 0
- if isinstance(elem._parent, FiniteField_prime_modn):
+
+ if isinstance(elem._parent, FiniteField_prime_modn) and _ring.cf.type == n_Zp:
return n_Init(int(elem),_ring.cf)
elif isinstance(elem._parent, RationalField):
@@ -1649,8 +1658,6 @@ cdef number *sa2si(Element elem, ring * _ring) noexcept:
elif isinstance(elem._parent, NumberField) and elem._parent.is_absolute():
return sa2si_NF(elem, _ring)
elif isinstance(elem._parent, IntegerModRing_generic):
- if _ring.cf.type == n_unknown:
- return n_Init(int(elem),_ring.cf)
return sa2si_ZZmod(elem, _ring)
elif isinstance(elem._parent, FractionField_generic) and isinstance(elem._parent.base(), (MPolynomialRing_libsingular, PolynomialRing_field)):
if isinstance(elem._parent.base().base_ring(), RationalField):
@@ -1806,9 +1813,99 @@ saved_PATH = os.environ["PATH"]
init_libsingular()
os.environ["PATH"] = saved_PATH
+cdef bint catching_error = False
+
cdef void libsingular_error_callback(const_char_ptr s) noexcept:
_s = char_to_str(s)
- error_messages.append(_s)
+ if catching_error:
+ error_messages.append(_s)
+ else:
+ warn(f"error in Singular ignored: {_s}")
+
+cdef int start_catch_error() except -1:
+ """
+ Helper function to convert Singular errors to Python exceptions.
+
+ Must be used as follows::
+
+ start_catch_error()
+ ...
+ s = check_error() # nonempty tuple[str, ...] (error messages) or None
+ if s:
+ # at this point global variable ``error_messages`` is cleared
+ raise RuntimeError(...)
+
+ Return value is ignored, only used for exception handling.
+
+ Note that :func:`check_error` can only be called exactly once.
+
+ Note that this *must not* be used in conjunction with :func:`sig_on` as follows::
+
+ start_catch_error()
+ sig_on()
+ ...
+ sig_off()
+ if check_error():
+ raise RuntimeError(...)
+
+ because if the code is interrupted, then :func:`check_error` is never called.
+
+ Use the following instead::
+
+ start_catch_error()
+ try:
+ sig_on()
+ ... # long time
+ sig_off()
+ finally:
+ if check_error():
+ raise RuntimeError(...)
+
+ If the code inside (marked `# long time`) can also raise a Python exception,
+ the above is still wrong --- :func:`sig_off` may not be called. In this case
+ use a nested ``try`` as suggested in ``cysignals`` documentation::
+
+ start_catch_error()
+ try:
+ sig_on() # This must be OUTSIDE the inner try
+ try:
+ ... # long time
+ finally:
+ sig_off()
+ finally:
+ if check_error():
+ raise RuntimeError(...)
+ """
+ global errorreported, catching_error, error_messages
+ if catching_error:
+ warn("internal error: previous start_catch_error not ended with check_error")
+ catching_error = True
+
+ if errorreported:
+ warn(f"error in Singular ignored: {', '.join(error_messages)}")
+ errorreported = False
+ error_messages.clear()
+ else:
+ assert not error_messages
+ return 0
+
+cdef object check_error():
+ """
+ See :func:`start_catch_error`.
+ """
+ global errorreported, catching_error, error_messages
+ if not catching_error:
+ warn("internal error: check_error not preceded with start_catch_error")
+ catching_error = False
+
+ if errorreported:
+ result = tuple(error_messages)
+ assert result
+ errorreported = False
+ error_messages.clear()
+ return result
+ assert not error_messages
+ return None
def get_resource(id):
diff --git a/src/sage/manifolds/differentiable/automorphismfield.py b/src/sage/manifolds/differentiable/automorphismfield.py
index c8f2143beb2..320620a0d8b 100644
--- a/src/sage/manifolds/differentiable/automorphismfield.py
+++ b/src/sage/manifolds/differentiable/automorphismfield.py
@@ -1199,7 +1199,7 @@ def __invert__(self):
if isinstance(frame, CoordFrame):
chart = frame._chart
else:
- chart = self._domain._def_chart #!# to be improved
+ chart = self._domain._def_chart # ! # to be improved
try:
# TODO: do the computation without the 'SR' enforcement
mat_self = matrix(
@@ -1370,7 +1370,7 @@ def at(self, point):
if dest_map.is_identity():
amb_point = point
else:
- amb_point = dest_map(point) # "ambient" point
+ amb_point = dest_map(point) # "ambient" point
ts = amb_point._manifold.tangent_space(amb_point)
if self._is_identity:
return ts.identity_map()
diff --git a/src/sage/manifolds/differentiable/integrated_curve.py b/src/sage/manifolds/differentiable/integrated_curve.py
index 77d6a419325..8b2d1f0251c 100644
--- a/src/sage/manifolds/differentiable/integrated_curve.py
+++ b/src/sage/manifolds/differentiable/integrated_curve.py
@@ -1096,7 +1096,7 @@ def solve(self, step=None, method='odeint', solution_key=None,
# raise error if coordinates in chart cannot be obtained
initial_coord_basis = chart.frame().at(initial_pt)
- initial_tgt_vec_comps = list(v0[initial_coord_basis,:]) #idem
+ initial_tgt_vec_comps = list(v0[initial_coord_basis,:]) # idem
dim = self.codomain().dim()
@@ -2372,15 +2372,15 @@ def plot_integrated(self, chart=None, ambient_coords=None,
else:
if across_charts:
for key in self._interpolations:
- if key[-8:-1] != '_chart_': # check if not a subplot
+ if key[-8:-1] != '_chart_': # check if not a subplot
interpolation_key = key
break
else:
raise ValueError("Did you forget to "
"integrate or interpolate the result?")
else:
- interpolation_key = next(iter(self._interpolations)) #will
- # raise error if self._interpolations empty
+ interpolation_key = next(iter(self._interpolations))
+ # will raise error if self._interpolations empty
if verbose:
print("Plotting from the interpolation associated " +
@@ -2484,7 +2484,7 @@ def plot_integrated(self, chart=None, ambient_coords=None,
raise ValueError("the argument prange must be a " +
"tuple/list of 2 elements")
else:
- p = prange #'p' declared only for the line below to be shorter
+ p = prange # 'p' declared only for the line below to be shorter
if p[0] < param_min or p[0] > param_max or p[1] < param_min or p[1] > param_max:
raise ValueError("parameter range should be a " +
"subinterval of the curve domain " +
@@ -3972,18 +3972,19 @@ def system(self, verbose=False):
if verbose:
initial_tgt_space = v0.parent()
- initial_pt = initial_tgt_space.base_point()#retrieves
- # the initial point as the base point of the tangent space
- # to which initial tangent vector belongs
+ initial_pt = initial_tgt_space.base_point()
+ # retrieves the initial point as the base point of the
+ # tangent space to which initial tangent vector belongs
+
initial_pt_coords = list(initial_pt.coordinates(chart))
- # previous line converts to list since would otherwise be a
- # tuple ; will raise error if coordinates in chart are not
- # known
+ # previous line converts to list since would otherwise be
+ # a tuple ; will raise error if coordinates in chart are
+ # not known
initial_coord_basis = chart.frame().at(initial_pt)
- initial_tgt_vec_comps = v0[initial_coord_basis,:] # will
- # raise error if components in coordinate basis are not
- # known
+ initial_tgt_vec_comps = v0[initial_coord_basis,:]
+ # will raise error if components in coordinate basis are
+ # not known
description = "Geodesic "
if self._name is not None:
diff --git a/src/sage/manifolds/differentiable/tensorfield_paral.py b/src/sage/manifolds/differentiable/tensorfield_paral.py
index 3fa7166234c..08b151e50c9 100644
--- a/src/sage/manifolds/differentiable/tensorfield_paral.py
+++ b/src/sage/manifolds/differentiable/tensorfield_paral.py
@@ -2118,7 +2118,7 @@ def at(self, point):
if dest_map.is_identity():
amb_point = point
else:
- amb_point = dest_map(point) # "ambient" point
+ amb_point = dest_map(point) # "ambient" point
ts = amb_point._manifold.tangent_space(amb_point)
resu = ts.tensor(self._tensor_type, name=self._name,
latex_name=self._latex_name, sym=self._sym,
diff --git a/src/sage/manifolds/differentiable/vectorframe.py b/src/sage/manifolds/differentiable/vectorframe.py
index 8cc75ab0f2d..a4df55bd276 100644
--- a/src/sage/manifolds/differentiable/vectorframe.py
+++ b/src/sage/manifolds/differentiable/vectorframe.py
@@ -1404,7 +1404,7 @@ def at(self, point):
"""
# Case of a non-trivial destination map
if self._from_frame is not None:
- if self._dest_map.is_identity(): #!# probably not necessary
+ if self._dest_map.is_identity(): # ! # probably not necessary
raise ValueError("the destination map should not be the identity")
ambient_point = self._dest_map(point)
return self._from_frame.at(ambient_point)
diff --git a/src/sage/matrix/matrix_space.py b/src/sage/matrix/matrix_space.py
index 2ba59292d54..7f5cb645134 100644
--- a/src/sage/matrix/matrix_space.py
+++ b/src/sage/matrix/matrix_space.py
@@ -297,7 +297,7 @@ def get_matrix_class(R, nrows, ncols, sparse, implementation):
except ImportError:
pass
else:
- if isinstance(R, polynomial_ring.PolynomialRing_general) and R.base_ring() in _Fields:
+ if isinstance(R, polynomial_ring.PolynomialRing_generic) and R.base_ring() in _Fields:
try:
from . import matrix_polynomial_dense
except ImportError:
diff --git a/src/sage/matrix/meson.build b/src/sage/matrix/meson.build
index a0168c1a117..0e51c764de7 100644
--- a/src/sage/matrix/meson.build
+++ b/src/sage/matrix/meson.build
@@ -2,6 +2,7 @@ iml = cc.find_library('iml')
py.install_sources(
+ '__init__.py',
'action.pxd',
'all.py',
'all__sagemath_meataxe.py',
diff --git a/src/sage/matroids/basis_exchange_matroid.pyx b/src/sage/matroids/basis_exchange_matroid.pyx
index 7cf056c4292..8b04ad20205 100644
--- a/src/sage/matroids/basis_exchange_matroid.pyx
+++ b/src/sage/matroids/basis_exchange_matroid.pyx
@@ -996,7 +996,7 @@ cdef class BasisExchangeMatroid(Matroid):
sage: setprint(M.components())
[{0, 1, 3, 4}, {2, 5}]
"""
- cdef long i,j,e
+ cdef long i, j, e
if not self._E:
return SetSystem(self._E)
cdef bitset_t *comp
@@ -1098,15 +1098,15 @@ cdef class BasisExchangeMatroid(Matroid):
cdef bitset_t SS, TT
bitset_init(SS, self._groundset_size)
bitset_init(TT, self._groundset_size)
- self._pack(SS,S)
- self._pack(TT,T)
- #F = set(self.groundset()) - (S | T)
+ self._pack(SS, S)
+ self._pack(TT, T)
+ # F = set(self.groundset()) - (S | T)
cdef bitset_t F, I
bitset_init(F, self._groundset_size)
bitset_init(I, self._groundset_size)
bitset_union(self._input, SS, TT)
bitset_complement(F, self._input)
- #I = self._augment(S|T, F)
+ # I = self._augment(S|T, F)
self.__augment(I, self._input, F)
cdef bitset_t X, X1, X2, next_layer, todo, out_neighbors, R
bitset_init(X, self._groundset_size)
@@ -1121,52 +1121,52 @@ cdef class BasisExchangeMatroid(Matroid):
cdef long e, u, y
cdef bint found_path = True
while found_path:
- #X = F - I
- bitset_difference(X,F,I)
- #X1 = X - self._closure(T|I)
+ # X = F - I
+ bitset_difference(X, F, I)
+ # X1 = X - self._closure(T|I)
bitset_union(self._input, TT, I)
self.__closure(X1, self._input)
- bitset_difference(X1,X,X1)
- #X2 = X - self._closure(S|I)
+ bitset_difference(X1, X, X1)
+ # X2 = X - self._closure(S|I)
bitset_union(self._input, SS, I)
self.__closure(X2, self._input)
- bitset_difference(X2,X,X2)
+ bitset_difference(X2, X, X2)
bitset_intersection(R, X1, X2)
e = bitset_first(R)
if e >= 0:
bitset_add(I, e)
continue
- #predecessor = {x: None for x in X1}
+ # predecessor = {x: None for x in X1}
e = bitset_first(X1)
while e>=0:
predecessor[e] = -1
e = bitset_next(X1, e+1)
- #next_layer = set(X1)
+ # next_layer = set(X1)
bitset_copy(next_layer, X1)
bitset_union(R, SS, X1)
found_path = False
while not bitset_isempty(next_layer) and not found_path:
- #todo = next_layer
- bitset_copy(todo,next_layer)
- #next_layer = {}
+ # todo = next_layer
+ bitset_copy(todo, next_layer)
+ # next_layer = {}
bitset_clear(next_layer)
u = bitset_first(todo)
- while u>=0 and not found_path:
- if bitset_in(X,u):
- #out_neighbors = self._circuit(I|S.union([u])) - S.union([u])
+ while u >= 0 and not found_path:
+ if bitset_in(X, u):
+ # out_neighbors = self._circuit(I|S.union([u])) - S.union([u])
bitset_union(self._input, I, SS)
bitset_add(self._input, u)
self.__circuit(out_neighbors, self._input)
bitset_discard(out_neighbors, u)
else:
- #out_neighbors = X - self._closure(I|T - set([u]))
+ # out_neighbors = X - self._closure(I|T - set([u]))
bitset_union(self._input, I, TT)
bitset_discard(self._input, u)
self.__closure(out_neighbors, self._input)
bitset_difference(out_neighbors, X, out_neighbors)
bitset_difference(out_neighbors, out_neighbors, R)
y = bitset_first(out_neighbors)
- while y>=0:
+ while y >= 0:
predecessor[y] = u
if bitset_in(X2, y):
found_path = True
@@ -1552,7 +1552,7 @@ cdef class BasisExchangeMatroid(Matroid):
res._append(I[i+1])
bitset_copy(self._input, I[i+1])
self.__closure(T[i+1], self._input)
- bitset_union(T[i+1],T[i+1],T[i])
+ bitset_union(T[i+1], T[i+1], T[i])
i = i + 1
else:
i = i - 1
@@ -2102,7 +2102,7 @@ cdef class BasisExchangeMatroid(Matroid):
from sage.matroids.basis_matroid import BasisMatroid
other = BasisMatroid(other)
if self is other:
- return {e:e for e in self.groundset()}
+ return {e: e for e in self.groundset()}
if len(self) != len(other):
return None
if self.full_rank() != other.full_rank():
diff --git a/src/sage/matroids/basis_matroid.pyx b/src/sage/matroids/basis_matroid.pyx
index b74a76af956..73c75f27b01 100644
--- a/src/sage/matroids/basis_matroid.pyx
+++ b/src/sage/matroids/basis_matroid.pyx
@@ -955,7 +955,7 @@ cdef class BasisMatroid(BasisExchangeMatroid):
if not isinstance(other, BasisMatroid):
return self.isomorphism(BasisMatroid(other))
if self is other:
- return {e:e for e in self.groundset()}
+ return {e: e for e in self.groundset()}
if len(self) != len(other):
return None
if self.full_rank() != other.full_rank():
diff --git a/src/sage/matroids/chow_ring_ideal.py b/src/sage/matroids/chow_ring_ideal.py
index f2a6c6cf477..8c067432b33 100644
--- a/src/sage/matroids/chow_ring_ideal.py
+++ b/src/sage/matroids/chow_ring_ideal.py
@@ -53,7 +53,7 @@ def _lattice_flats(self):
flats = list(lattice_flats)
flats.sort(key=lambda X: (len(X), sorted(X)))
ranks = {F: self._matroid.rank(F) for F in flats}
- chains = lattice_flats.chains() #Only chains
+ chains = lattice_flats.chains() # Only chains
return (ranks, chains)
@@ -118,8 +118,8 @@ def __init__(self, M, R):
for X in self._matroid.flats(i)]
names = ['A{}'.format(''.join(str(x) for x in sorted(F, key=cmp_elements_key))) for F in flats]
try:
- poly_ring = PolynomialRing(R, names) #self.ring
- except ValueError: # variables are not proper names
+ poly_ring = PolynomialRing(R, names) # self.ring
+ except ValueError: # variables are not proper names
poly_ring = PolynomialRing(R, 'A', len(flats))
gens = poly_ring.gens()
self._flats_generator = dict(zip(flats, gens))
@@ -394,8 +394,8 @@ def __init__(self, M, R):
try:
names_groundset = ['A{}'.format(''.join(str(x))) for x in E]
names_flats = ['B{}'.format(''.join(str(x) for x in sorted(F, key=cmp_elements_key))) for F in self._flats]
- poly_ring = PolynomialRing(R, names_groundset + names_flats) #self.ring()
- except ValueError: #variables are not proper names
+ poly_ring = PolynomialRing(R, names_groundset + names_flats) # self.ring()
+ except ValueError: # variables are not proper names
poly_ring = PolynomialRing(R, 'A', len(E) + len(self._flats))
for i, x in enumerate(E):
self._flats_generator[x] = poly_ring.gens()[i]
@@ -528,7 +528,7 @@ def groebner_basis(self, algorithm='', *args, **kwargs):
for H in lattice_flats.order_filter([F]):
term1 += self._flats_generator[H]
if term1 != poly_ring.zero():
- gb.append(term1**(self._matroid.rank(F) + 1)) #5.6 (MM2022)
+ gb.append(term1**(self._matroid.rank(F) + 1)) # 5.6 (MM2022)
order_ideal_modified = lattice_flats.order_ideal([F])
order_ideal_modified.remove(F)
for G in order_ideal_modified: # nested flats
@@ -645,8 +645,8 @@ def __init__(self, M, R):
for X in self._matroid.flats(i)]
names = ['A{}'.format(''.join(str(x) for x in sorted(F, key=cmp_elements_key))) for F in self._flats]
try:
- poly_ring = PolynomialRing(R, names) #self.ring
- except ValueError: # variables are not proper names
+ poly_ring = PolynomialRing(R, names) # self.ring
+ except ValueError: # variables are not proper names
poly_ring = PolynomialRing(R, 'A', len(self._flats))
gens = poly_ring.gens()
self._flats_generator = dict(zip(self._flats, gens))
diff --git a/src/sage/matroids/circuit_closures_matroid.pyx b/src/sage/matroids/circuit_closures_matroid.pyx
index a4251298ebc..72cd1c4fc16 100644
--- a/src/sage/matroids/circuit_closures_matroid.pyx
+++ b/src/sage/matroids/circuit_closures_matroid.pyx
@@ -62,7 +62,8 @@ from cpython.object cimport Py_EQ, Py_NE
from sage.structure.richcmp cimport rich_to_bool, richcmp
from sage.matroids.matroid cimport Matroid
from sage.matroids.set_system cimport SetSystem
-from sage.matroids.utilities import setprint_s, cmp_elements_key
+from sage.matroids.utilities import setprint_s
+
cdef class CircuitClosuresMatroid(Matroid):
r"""
diff --git a/src/sage/matroids/circuits_matroid.pyx b/src/sage/matroids/circuits_matroid.pyx
index cd44db7772b..a93efd85b33 100644
--- a/src/sage/matroids/circuits_matroid.pyx
+++ b/src/sage/matroids/circuits_matroid.pyx
@@ -186,7 +186,6 @@ cdef class CircuitsMatroid(Matroid):
6
"""
cdef set XX = set(X)
- cdef int i
cdef frozenset C
while True:
try:
diff --git a/src/sage/matroids/graphic_matroid.pyx b/src/sage/matroids/graphic_matroid.pyx
index 53bd8adef39..c718535b4aa 100644
--- a/src/sage/matroids/graphic_matroid.pyx
+++ b/src/sage/matroids/graphic_matroid.pyx
@@ -608,7 +608,7 @@ cdef class GraphicMatroid(Matroid):
# then use method from abstract matroid class
conset, delset = sanitize_contractions_deletions(self, contractions, deletions)
M = self._minor(contractions=conset, deletions=delset)
- should_be_true, elements = Matroid._has_minor(M, N, certificate=True)
+ _, elements = Matroid._has_minor(M, N, certificate=True)
# elements is a tuple (contractions, deletions, dict)
# There should be no more contractions
diff --git a/src/sage/matroids/lean_matrix.pyx b/src/sage/matroids/lean_matrix.pyx
index e0f86c6db83..82de4b9a648 100644
--- a/src/sage/matroids/lean_matrix.pyx
+++ b/src/sage/matroids/lean_matrix.pyx
@@ -521,16 +521,16 @@ cdef class LeanMatrix:
for z in range(self.ncols()):
if z in P_cols+Q_cols:
continue
- sol,cert = self.shifting(P_rows,P_cols,Q_rows,Q_cols,z,None,m)
+ sol, cert = self.shifting(P_rows, P_cols, Q_rows, Q_cols, z, None, m)
if sol:
return True, cert
- sol,cert = self.shifting(Q_rows,Q_cols,P_rows,P_cols,None,z,m)
+ sol, cert = self.shifting(Q_rows, Q_cols, P_rows, P_cols, None, z, m)
if sol:
return True, cert
- sol,cert = self.shifting(P_rows,P_cols,Q_rows,Q_cols,None,z,m)
+ sol, cert = self.shifting(P_rows, P_cols, Q_rows, Q_cols, None, z, m)
if sol:
return True, cert
- sol,cert = self.shifting(Q_rows,Q_cols,P_rows,P_cols,z,None,m)
+ sol, cert = self.shifting(Q_rows, Q_cols, P_rows, P_cols, z, None, m)
if sol:
return True, cert
return False, None
@@ -600,26 +600,29 @@ cdef class LeanMatrix:
B = self.matrix_from_rows_and_columns(list(U_1), range(len(Y)))
B.gauss_jordan_reduce(lV_2)
# find a unique representation of every rows in X_3xV_1 using rows in U_2xV_1
- BT = self.matrix_from_rows_and_columns(range(len(X)),list(V_1)).transpose()
+ BT = self.matrix_from_rows_and_columns(range(len(X)),
+ list(V_1)).transpose()
BT.gauss_jordan_reduce(lU_2)
cdef set X_p = set(X_1)
cdef set Y_p = set(Y_1)
while True:
- #rowshifts
- X_p_new = set([])
+ # rowshifts
+ X_p_new = set()
for x in set(X_3):
for y in Y_p:
- if sum([BT.get_unsafe(rU[u],x)*self.get_unsafe(u,y) for u in U_2]) != self.get_unsafe(x,y):
+ if sum([BT.get_unsafe(rU[u], x) * self.get_unsafe(u, y)
+ for u in U_2]) != self.get_unsafe(x, y):
X_1.append(x)
X_3.remove(x)
X_p_new.add(x)
break
- #colshifts
- Y_p_new = set([])
+ # colshifts
+ Y_p_new = set()
for y in set(Y_3):
for x in X_p:
- if sum([B.get_unsafe(rV[v],y)*self.get_unsafe(x,v) for v in V_2]) != self.get_unsafe(x,y):
+ if sum([B.get_unsafe(rV[v], y) * self.get_unsafe(x, v)
+ for v in V_2]) != self.get_unsafe(x, y):
Y_1.append(y)
Y_3.remove(y)
Y_p_new.add(y)
@@ -1327,7 +1330,7 @@ cdef class BinaryMatrix(LeanMatrix):
for r in range(len(rows)):
row = self._M[rows[r]]
row2 = A._M[r]
- bitset_intersection(row2, row, mask) # yes, this is safe
+ bitset_intersection(row2, row, mask) # yes, this is safe
for g in range(lg):
if bitset_in(row, cols[g]):
bitset_add(row2, gaps[g])
@@ -2006,8 +2009,8 @@ cdef class TernaryMatrix(LeanMatrix):
row1 = self._M1[rows[r]]
row0_2 = A._M0[r]
row1_2 = A._M1[r]
- bitset_intersection(row0_2, row0, mask) # yes, this is safe
- bitset_intersection(row1_2, row1, mask) # yes, this is safe
+ bitset_intersection(row0_2, row0, mask) # yes, this is safe
+ bitset_intersection(row1_2, row1, mask) # yes, this is safe
for g in range(lg):
p = cols[g]
if bitset_in(row0, p):
@@ -2590,7 +2593,7 @@ cdef class QuaternaryMatrix(LeanMatrix):
row1 = self._M1[rows[r]]
row0_2 = A._M0[r]
row1_2 = A._M1[r]
- bitset_intersection(row0_2, row0, mask) # yes, this is safe
+ bitset_intersection(row0_2, row0, mask) # yes, this is safe
bitset_intersection(row1_2, row1, mask)
for g in range(lg):
p = cols[g]
@@ -3233,11 +3236,11 @@ cdef class RationalMatrix(LeanMatrix):
elif isinstance(M, LeanMatrix):
for i in range(M.nrows()):
for j in range(M.ncols()):
- mpq_set(self._entries[i * self._ncols + j], Rational((M).get_unsafe(i,j)).value)
+ mpq_set(self._entries[i * self._ncols + j], Rational((M).get_unsafe(i, j)).value)
else: # Sage Matrix or otherwise
for i in range(M.nrows()):
for j in range(M.ncols()):
- mpq_set(self._entries[i * self._ncols + j], Rational(M[i,j]).value)
+ mpq_set(self._entries[i * self._ncols + j], Rational(M[i, j]).value)
def __dealloc__(self):
"""
@@ -3358,7 +3361,7 @@ cdef class RationalMatrix(LeanMatrix):
A = RationalMatrix(self._nrows, self._ncols + Mn)
for i in range(self._nrows):
for j in range(self._ncols):
- mpq_set(A._entries[A.index(i,j)], self._entries[self.index(i,j)])
+ mpq_set(A._entries[A.index(i, j)], self._entries[self.index(i, j)])
mpq_set(A._entries[i*A._ncols + self._ncols + j], (M)._entries[i*Mn + j])
return A
@@ -3366,9 +3369,10 @@ cdef class RationalMatrix(LeanMatrix):
cdef RationalMatrix A = RationalMatrix(self._nrows, self._ncols + self._nrows)
cdef long i, j
for i in range(self._nrows):
- mpq_set_si(A._entries[A.index(i,i)], 1, 1)
+ mpq_set_si(A._entries[A.index(i, i)], 1, 1)
for j in range(self._ncols):
- mpq_set(A._entries[A.index(i,self._nrows+j)], self._entries[self.index(i,j)])
+ mpq_set(A._entries[A.index(i, self._nrows + j)],
+ self._entries[self.index(i, j)])
return A
cpdef base_ring(self):
diff --git a/src/sage/matroids/linear_matroid.pyx b/src/sage/matroids/linear_matroid.pyx
index 9030ce47f25..02d1d3c28d9 100644
--- a/src/sage/matroids/linear_matroid.pyx
+++ b/src/sage/matroids/linear_matroid.pyx
@@ -2731,15 +2731,15 @@ cdef class LinearMatroid(BasisExchangeMatroid):
dX = dict(zip(range(len(X)), X))
dY = dict(zip(range(len(Y)), Y))
- for (x, y) in spanning_forest(M):
- P_rows=[x]
- P_cols=[y]
- Q_rows=[]
- Q_cols=[]
- sol,cert_pair = M2.shifting_all(P_rows, P_cols, Q_rows, Q_cols, 2)
+ for x, y in spanning_forest(M):
+ P_rows = [x]
+ P_cols = [y]
+ Q_rows = []
+ Q_cols = []
+ sol, cert_pair = M2.shifting_all(P_rows, P_cols, Q_rows, Q_cols, 2)
if sol:
if certificate:
- cert = set([])
+ cert = set()
for x in cert_pair[0]:
cert.add(dX[x])
for y in cert_pair[1]:
@@ -2795,8 +2795,8 @@ cdef class LinearMatroid(BasisExchangeMatroid):
M = M2._matrix_()
X, Y = self._current_rows_cols()
- dX = dict(zip(range(len(X)),X))
- dY = dict(zip(range(len(Y)),Y))
+ dX = dict(zip(range(len(X)), X))
+ dY = dict(zip(range(len(Y)), Y))
n = len(X)
m = len(Y)
@@ -2817,22 +2817,22 @@ cdef class LinearMatroid(BasisExchangeMatroid):
Yp = list(range(m))
Yp.remove(y1)
- B = B.matrix_from_rows_and_columns(Xp,Yp)
+ B = B.matrix_from_rows_and_columns(Xp, Yp)
# produce a spanning forest of B
- for (x,y) in spanning_forest(B):
+ for x, y in spanning_forest(B):
if x >= x1:
x = x + 1
if y >= y1:
y = y + 1
# rank 2 matrix and rank 0 matrix
- P_rows = [x,x1]
- P_cols = [y,y1]
+ P_rows = [x, x1]
+ P_cols = [y, y1]
Q_rows = []
Q_cols = []
# make sure the matrix has rank 2
- if M.matrix_from_rows_and_columns(P_rows,P_cols).rank() == 2:
- sol,cert_pair = M2.shifting_all(P_rows, P_cols, Q_rows, Q_cols, 3)
+ if M.matrix_from_rows_and_columns(P_rows, P_cols).rank() == 2:
+ sol, cert_pair = M2.shifting_all(P_rows, P_cols, Q_rows, Q_cols, 3)
if sol:
break
# rank 1 matrix and rank 1 matrix
@@ -2841,7 +2841,7 @@ cdef class LinearMatroid(BasisExchangeMatroid):
Q_rows = [x]
Q_cols = [y]
# both matrix have rank 1
- sol,cert_pair = M2.shifting_all(P_rows, P_cols, Q_rows, Q_cols, 3)
+ sol, cert_pair = M2.shifting_all(P_rows, P_cols, Q_rows, Q_cols, 3)
if sol:
break
if sol:
@@ -2906,7 +2906,7 @@ cdef class LinearMatroid(BasisExchangeMatroid):
if action in Semigroups:
G, action = action, G
else:
- G, action = G_action, None # the None action is g.__call__
+ G, action = G_action, None # the None action is g.__call__
from sage.algebras.orlik_terao import OrlikTeraoInvariantAlgebra
@@ -3835,7 +3835,7 @@ cdef class BinaryMatroid(LinearMatroid):
global GF2
cdef int r, c
B= self.basis()
- C = [self._fundamental_cocircuit(B,e) for e in B]
+ C = [self._fundamental_cocircuit(B, e) for e in B]
c = 1
col = {}
@@ -3850,21 +3850,22 @@ cdef class BinaryMatroid(LinearMatroid):
for f in range(e):
for g in range(f):
if not C[e].issuperset(C[f] & C[g]):
- M.append([col[e,f], col[e,g]])
+ M.append([col[e, f], col[e, g]])
r += 1
if not C[f].issuperset(C[e] & C[g]):
- M.append([col[f,e], col[f,g]])
+ M.append([col[f, e], col[f, g]])
r += 1
if not C[g].issuperset(C[e] & C[f]):
- M.append([col[g,e], col[g,f]])
+ M.append([col[g, e], col[g, f]])
r += 1
if len(C[e] & C[f] & C[g]) > 0:
- M.append([0,col[e,f], col[e,g], col[f,e], col[f,g], col[g,e], col[g,f]])
+ M.append([0, col[e, f], col[e, g], col[f, e],
+ col[f, g], col[g, e], col[g, f]])
r += 1
cdef BinaryMatrix m = BinaryMatrix(r, c)
for r in range(len(M)):
for c in M[r]:
- m.set(r,c)
+ m.set(r, c)
# now self is graphic iff there is a binary vector x so that M*x = 0 and x_0 = 1, so:
return BinaryMatroid(m).corank(frozenset([0])) > 0
@@ -4730,9 +4731,9 @@ cdef class TernaryMatroid(LinearMatroid):
C = [self._idx[f] for f in F]
A, C2 = (self._A).matrix_from_rows_and_columns_reordered(R, C)
return TernaryMatroid(matrix=A,
- groundset=[self._E[c] for c in C2],
- basis=bas,
- keep_initial_representation=False)
+ groundset=[self._E[c] for c in C2],
+ basis=bas,
+ keep_initial_representation=False)
cpdef is_valid(self, certificate=False):
r"""
@@ -5498,9 +5499,9 @@ cdef class QuaternaryMatroid(LinearMatroid):
C = [self._idx[f] for f in F]
A, C2 = (self._A).matrix_from_rows_and_columns_reordered(R, C)
return QuaternaryMatroid(matrix=A,
- groundset=[self._E[c] for c in C2],
- basis=bas,
- keep_initial_representation=False)
+ groundset=[self._E[c] for c in C2],
+ basis=bas,
+ keep_initial_representation=False)
cpdef is_valid(self, certificate=False):
r"""
@@ -6166,8 +6167,9 @@ cdef class RegularMatroid(LinearMatroid):
VO.extend(X)
m = isomorphic(HS[2], HO[2], HS[0], VO, 1, 1)
if m:
- idx={str(f):f for f in other.groundset()}
- return {e:idx[m[str(e)]] for e in self.groundset() if str(e) in m}
+ idx = {str(f): f for f in other.groundset()}
+ return {e: idx[m[str(e)]] for e in self.groundset()
+ if str(e) in m}
cpdef has_line_minor(self, k, hyperlines=None, certificate=False):
r"""
diff --git a/src/sage/matroids/matroid.pyx b/src/sage/matroids/matroid.pyx
index ff853ba9f5a..fab7b9008bf 100644
--- a/src/sage/matroids/matroid.pyx
+++ b/src/sage/matroids/matroid.pyx
@@ -3415,7 +3415,7 @@ cdef class Matroid(SageObject):
if action in Semigroups:
G, action = action, G
else:
- G, action = G_action, None # the None action is g.__call__
+ G, action = G_action, None # the None action is g.__call__
from sage.algebras.orlik_solomon import OrlikSolomonInvariantAlgebra
@@ -3669,7 +3669,7 @@ cdef class Matroid(SageObject):
False
"""
if self is other:
- return {e:e for e in self.groundset()}
+ return {e: e for e in self.groundset()}
if self.full_rank() == other.full_rank():
return SetSystem(self.groundset(), self.nonbases())._isomorphism(SetSystem(other.groundset(), other.nonbases()))
else:
@@ -5204,7 +5204,7 @@ cdef class Matroid(SageObject):
sage: M._connectivity(frozenset('ab'), frozenset('cd'))
2
"""
- return len(self._link(S,T)[0]) - self.full_rank() + self.rank(S) + self.rank(T)
+ return len(self._link(S, T)[0]) - self.full_rank() + self.rank(S) + self.rank(T)
cpdef link(self, S, T):
r"""
@@ -5409,7 +5409,7 @@ cdef class Matroid(SageObject):
continue
# Given Q1, Q2 partition of Q, find all extensions
for r2 in range(r+1):
- for R1 in map(set,combinations(R, r2)):
+ for R1 in map(set, combinations(R, r2)):
R2 = R - R1
# F is the set of elements cannot be in the extension of Q1
F = set([])
@@ -5417,7 +5417,7 @@ cdef class Matroid(SageObject):
# if Q1|R1 is full
if m-len(Q1)-len(R1) == 0:
T = frozenset(Q1 | R1)
- for B in map(set,combinations(U, m-len(Q2)-len(R2))):
+ for B in map(set, combinations(U, m-len(Q2)-len(R2))):
S = frozenset(Q2 | R2 | B)
_, X = self._link(S, T)
if self.connectivity(X) < m:
@@ -5434,7 +5434,7 @@ cdef class Matroid(SageObject):
# extension of Q2 is full
if len(F) == m-len(Q2)-len(R2):
S = frozenset(Q2 | R2 | F)
- for A in map(set, combinations(U,m-len(Q1)-len(R1))):
+ for A in map(set, combinations(U, m-len(Q1)-len(R1))):
T = frozenset(Q1 | R1 | A)
_, X = self._link(S, T)
if self.connectivity(X) < m:
@@ -5669,7 +5669,7 @@ cdef class Matroid(SageObject):
T = frozenset([g, h])
I, X = self._link(S, T)
# check if connectivity between S,T is < 2
- if len(I) + 2 < self.full_rank(): # note: rank(S) = rank(T) = 2
+ if len(I) + 2 < self.full_rank(): # note: rank(S) = rank(T) = 2
if certificate:
return False, X
else:
@@ -5685,7 +5685,7 @@ cdef class Matroid(SageObject):
T = frozenset([f, h])
I, X = self._link(S, T)
# check if connectivity between S,T is < 2
- if len(I) + 2 < self.full_rank(): # note: rank(S) = rank(T) = 2
+ if len(I) + 2 < self.full_rank(): # note: rank(S) = rank(T) = 2
if certificate:
return False, X
else:
@@ -5700,7 +5700,7 @@ cdef class Matroid(SageObject):
T = frozenset([e, h])
I, X = self._link(S, T)
# check if connectivity between S,T is < 2
- if len(I) + 2 < self.full_rank(): # note: rank(S) = rank(T) = 2
+ if len(I) + 2 < self.full_rank(): # note: rank(S) = rank(T) = 2
if certificate:
return False, X
else:
@@ -5774,12 +5774,12 @@ cdef class Matroid(SageObject):
for x in (X & self.fundamental_circuit(X, y)):
M[rdX[x], rdY[y]]=1
- for (x,y) in spanning_forest(M):
- P_rows=set([dX[x]])
- P_cols=set([dY[y]])
- Q_rows=set([])
- Q_cols=set([])
- sol,cert = self._shifting_all(X, P_rows, P_cols, Q_rows, Q_cols, 2)
+ for x, y in spanning_forest(M):
+ P_rows = set([dX[x]])
+ P_cols = set([dY[y]])
+ Q_rows = set()
+ Q_cols = set()
+ sol, cert = self._shifting_all(X, P_rows, P_cols, Q_rows, Q_cols, 2)
if sol:
if certificate:
return False, cert
@@ -5837,15 +5837,15 @@ cdef class Matroid(SageObject):
# the partial matrix
M = matrix(len(X), len(Y))
for y in Y:
- for x in (X & self.fundamental_circuit(X,y)):
- M[rdX[x],rdY[y]]=1
+ for x in (X & self.fundamental_circuit(X, y)):
+ M[rdX[x], rdY[y]] = 1
n = len(X)
m = len(Y)
# compute a connected set of stars
T = spanning_stars(M)
- for (x1,y1) in T:
+ for x1, y1 in T:
# The whiting out
B = M
for (x, y) in product(range(n), range(m)):
@@ -5858,20 +5858,20 @@ cdef class Matroid(SageObject):
Xp.remove(x1)
Yp = list(range(m))
Yp.remove(y1)
- B = B.matrix_from_rows_and_columns(Xp,Yp)
+ B = B.matrix_from_rows_and_columns(Xp, Yp)
# produce a spanning forest of B
- for (x,y) in spanning_forest(B):
+ for x, y in spanning_forest(B):
if x >= x1:
x = x+1
if y >= y1:
y = y+1
# rank 2 matrix and rank 0 matrix
- P_rows = set([dX[x],dX[x1]])
- P_cols = set([dY[y],dY[y1]])
- Q_rows = set([])
- Q_cols = set([])
- sol,cert = self._shifting_all(X, P_rows, P_cols, Q_rows, Q_cols, 3)
+ P_rows = set([dX[x], dX[x1]])
+ P_cols = set([dY[y], dY[y1]])
+ Q_rows = set()
+ Q_cols = set()
+ sol, cert = self._shifting_all(X, P_rows, P_cols, Q_rows, Q_cols, 3)
if sol:
if certificate:
return False, cert
@@ -5881,7 +5881,7 @@ cdef class Matroid(SageObject):
P_cols = set([dY[y1]])
Q_rows = set([dX[x]])
Q_cols = set([dY[y]])
- sol,cert = self._shifting_all(X, P_rows, P_cols, Q_rows, Q_cols, 3)
+ sol, cert = self._shifting_all(X, P_rows, P_cols, Q_rows, Q_cols, 3)
if sol:
if certificate:
return False, cert
@@ -5937,16 +5937,16 @@ cdef class Matroid(SageObject):
"""
Y = self.groundset()-X
for z in (Y - P_cols) - Q_cols:
- sol,cert = self._shifting(X,P_rows,P_cols|set([z]),Q_rows,Q_cols,m)
+ sol, cert = self._shifting(X, P_rows, P_cols|set([z]), Q_rows, Q_cols, m)
if sol:
return True, cert
- sol,cert = self._shifting(X,Q_rows,Q_cols,P_rows,P_cols|set([z]),m)
+ sol, cert = self._shifting(X, Q_rows, Q_cols, P_rows, P_cols|set([z]), m)
if sol:
return True, cert
- sol,cert = self._shifting(X,P_rows,P_cols,Q_rows,Q_cols|set([z]),m)
+ sol, cert = self._shifting(X, P_rows, P_cols, Q_rows, Q_cols|set([z]), m)
if sol:
return True, cert
- sol,cert = self._shifting(X,Q_rows,Q_cols|set([z]),P_rows,P_cols,m)
+ sol, cert = self._shifting(X, Q_rows, Q_cols|set([z]), P_rows, P_cols, m)
if sol:
return True, cert
return False, None
@@ -6008,26 +6008,26 @@ cdef class Matroid(SageObject):
Y = self.groundset()-X
# Returns true if there is a m-separator
if (self._rank(Y_2|(X-X_1)) - len(X-X_1)
- + self._rank(Y_1|(X-X_2)) - len(X-X_2) != m-1):
+ + self._rank(Y_1|(X-X_2)) - len(X-X_2) != m-1):
return False, None
if len(X_1|Y_1) < m:
return False, None
remainX = set(X-(X_1|X_2))
remainY = set(Y-(Y_1|Y_2))
while True:
- #rowshifts
+ # rowshifts
rowshift = False
for x in set(remainX):
if (self._rank(Y_1|(X-(X_2|set([x])))) - len(X-(X_2|set([x])))
- > self._rank(Y_1|(X-X_2)) - len(X-X_2)):
+ > self._rank(Y_1|(X-X_2)) - len(X-X_2)):
X_1 = X_1 | {x}
remainX.remove(x)
rowshift = True
- #colshifts
+ # colshifts
colshift = False
for y in set(remainY):
if (self._rank(Y_2|set([y])|(X-X_1)) - len(X-X_1)
- > self._rank(Y_2|(X-X_1)) - len(X-X_1)):
+ > self._rank(Y_2|(X-X_1)) - len(X-X_1)):
Y_1 = Y_1 | {y}
remainY.remove(y)
colshift = True
@@ -6353,7 +6353,7 @@ cdef class Matroid(SageObject):
True
"""
M = self._local_binary_matroid()
- m = {e:e for e in self.groundset()}
+ m = {e: e for e in self.groundset()}
if randomized_tests > 0:
E = list(self.groundset())
for r in range(randomized_tests):
@@ -6458,20 +6458,20 @@ cdef class Matroid(SageObject):
for C in G.connected_components_subgraphs():
T.update(C.min_spanning_tree())
for edge in T:
- e,f = edge[2]
- A.set(bdx[e],idx[f], 1)
+ e, f = edge[2]
+ A.set(bdx[e], idx[f], 1)
W = list(set(G.edges(sort=False)) - set(T))
H = G.subgraph(edges = T)
while W:
edge = W.pop(-1)
- e,f = edge[2]
+ e, f = edge[2]
path = H.shortest_path(e, f)
for i in range(len(W)):
edge2 = W[i]
if edge2[0] in path and edge2[1] in path:
W[i] = edge
edge = edge2
- e,f = edge[2]
+ e, f = edge[2]
while path[0]!= e and path[0] != f:
path.pop(0)
while path[-1]!= e and path[-1] != f:
@@ -6485,9 +6485,9 @@ cdef class Matroid(SageObject):
else:
x = x * A.get(bdx[path[i+1]], idx[path[i]])
if (len(path) % 4 == 0) == self.is_dependent(set(basis).symmetric_difference(path)):
- A.set(bdx[e],idx[f],x)
+ A.set(bdx[e], idx[f], x)
else:
- A.set(bdx[e],idx[f],-x)
+ A.set(bdx[e], idx[f], -x)
H.add_edge(edge)
from sage.matroids.linear_matroid import TernaryMatroid
return TernaryMatroid(groundset=E, matrix=A, basis=basis, keep_initial_representation=False)
@@ -6534,7 +6534,7 @@ cdef class Matroid(SageObject):
NonFano: Ternary matroid of rank 3 on 7 elements, type 0-
"""
M = self._local_ternary_matroid()
- m = {e:e for e in self.groundset()}
+ m = {e: e for e in self.groundset()}
if randomized_tests > 0:
E = list(self.groundset())
for r in range(randomized_tests):
@@ -6816,7 +6816,7 @@ cdef class Matroid(SageObject):
"""
cdef frozenset C
if k2 is None:
- k2 = len(self.groundset()) + 1 # This is always larger than the rank
+ k2 = len(self.groundset()) + 1 # This is always larger than the rank
for C in self.circuits_iterator():
if len(C) < k1 or len(C) > k2:
continue
@@ -7478,7 +7478,7 @@ cdef class Matroid(SageObject):
todo = set(X1)
next_layer = set()
while todo:
- while todo: # todo is subset of X
+ while todo: # todo is subset of X
u = todo.pop()
m = w[u]
if u not in out_neighbors:
@@ -7491,7 +7491,7 @@ cdef class Matroid(SageObject):
next_layer.add(y)
todo = next_layer
next_layer = set()
- while todo: # todo is subset of Y
+ while todo: # todo is subset of Y
u = todo.pop()
m = w[u]
if u not in out_neighbors:
@@ -7505,11 +7505,11 @@ cdef class Matroid(SageObject):
todo = next_layer
next_layer = set()
- X3 = X2.intersection(w) # w is the set of elements reachable from X1
- if not X3: # if no path from X1 to X2, then no augmenting set exists
+ X3 = X2.intersection(w) # w is the set of elements reachable from X1
+ if not X3: # if no path from X1 to X2, then no augmenting set exists
return False, frozenset(w)
else:
- s = min([w[x] for x in X3]) # find shortest length of an X1 - X2 path
+ s = min([w[x] for x in X3]) # find shortest length of an X1 - X2 path
for u in X3:
if w[u] == s:
break
@@ -7639,7 +7639,7 @@ cdef class Matroid(SageObject):
layers[dist] = set(todo)
if X3:
break
- while todo: # todo is subset of X
+ while todo: # todo is subset of X
u = todo.pop()
m = w[u]
if u not in out_neighbors:
@@ -7658,7 +7658,7 @@ cdef class Matroid(SageObject):
break
if not todo:
break
- while todo: # todo is subset of Y
+ while todo: # todo is subset of Y
u = todo.pop()
m = w[u]
if u not in out_neighbors:
@@ -7708,15 +7708,13 @@ cdef class Matroid(SageObject):
for v in layers[d[u]+1] - visited:
# check if edge (u,v) exists in the auxiliary digraph
exist = False
- if ((u in Y) and
- (v in E-Y) and
- (self.is_dependent(Y|set([v]))) and
- (self.is_independent((Y|set([v])) - set([u])))):
+ if ((u in Y) and (v in E-Y) and
+ (self.is_dependent(Y|{v})) and
+ (self.is_independent((Y|{v}) - {u}))):
exist = True
- if ((u in E-Y) and
- (v in Y) and
- (not other.is_independent(Y|set([u]))) and
- (other.is_independent((Y|set([u])) - set([v])))):
+ if ((u in E-Y) and (v in Y) and
+ (not other.is_independent(Y|{u})) and
+ (other.is_independent((Y|{u}) - {v}))):
exist = True
if exist:
stack.append(v)
@@ -8172,8 +8170,8 @@ cdef class Matroid(SageObject):
B = list(self.basis())
elif B is not None and not self.is_basis(B):
return
- lineorders2=matroids_plot_helpers.lineorders_union(self._cached_info['lineorders'],lineorders)
- return matroids_plot_helpers.geomrep(self,B,lineorders2,pd=pos_dict, sp=save_pos)
+ lineorders2 = matroids_plot_helpers.lineorders_union(self._cached_info['lineorders'], lineorders)
+ return matroids_plot_helpers.geomrep(self, B, lineorders2, pd=pos_dict, sp=save_pos)
cpdef show(self, B=None, lineorders=None, pos_method=None, pos_dict=None, save_pos=False, lims=None):
"""
@@ -8216,12 +8214,12 @@ cdef class Matroid(SageObject):
B = list(self.basis())
elif B is not None and not self.is_basis(B):
return
- B1=B
- lineorders1=lineorders
- pm=pos_method
- pd=pos_dict
- sp=save_pos
- G=self.plot(B1,lineorders1,pm,pd,sp)
+ B1 = B
+ lineorders1 = lineorders
+ pm = pos_method
+ pd = pos_dict
+ sp = save_pos
+ G = self.plot(B1, lineorders1, pm, pd, sp)
if lims is None:
G.show()
else:
@@ -8265,7 +8263,7 @@ cdef class Matroid(SageObject):
# check sanity of pos_dict and add it to cached info if sane
if pos_dict is not None:
from sage.matroids import matroids_plot_helpers
- if matroids_plot_helpers.posdict_is_sane(self,pos_dict):
+ if matroids_plot_helpers.posdict_is_sane(self, pos_dict):
self._cached_info = {'plot_positions': pos_dict, 'lineorders': lineorders}
return
@@ -8461,11 +8459,11 @@ cdef class Matroid(SageObject):
# constructed yet.
DM = IM.disjoint_union(SimplicialComplex())
- ## simplices are \{y_i\}_{i\in I}\cup\{x_{F_1},\ldots,x_{F_\ell}\},
- ## by [BMHPW20a]_ thm 4 it is pure of dimension r(M)-1
+ # simplices are \{y_i\}_{i\in I}\cup\{x_{F_1},\ldots,x_{F_\ell}\},
+ # by [BMHPW20a]_ thm 4 it is pure of dimension r(M)-1
for c in LM.chains(exclude=LM.maximal_elements()):
- if c: # the facets of IM are already present
+ if c: # the facets of IM are already present
# get the cardinality of intersection of facet with IM
r = self._rank(self.groundset()) - len(c)
diff --git a/src/sage/matroids/meson.build b/src/sage/matroids/meson.build
index f60970da5b9..8fd8ae12895 100644
--- a/src/sage/matroids/meson.build
+++ b/src/sage/matroids/meson.build
@@ -1,4 +1,5 @@
py.install_sources(
+ '__init__.py',
'advanced.py',
'all.py',
'basis_exchange_matroid.pxd',
diff --git a/src/sage/matroids/union_matroid.pyx b/src/sage/matroids/union_matroid.pyx
index e371d5fb313..86c78c8463d 100644
--- a/src/sage/matroids/union_matroid.pyx
+++ b/src/sage/matroids/union_matroid.pyx
@@ -97,11 +97,11 @@ cdef class MatroidUnion(Matroid):
summands.append(e.delete(e.groundset()-X))
sum_matroid = MatroidSum(summands)
d = {}
- for (i,x) in sum_matroid.groundset():
+ for i, x in sum_matroid.groundset():
if x not in d:
- d[x]=set()
+ d[x] = set()
d[x].add(i)
- part_matroid = PartitionMatroid([[(i,x) for i in d[x]] for x in d])
+ part_matroid = PartitionMatroid([[(i, x) for i in d[x]] for x in d])
return len(sum_matroid._intersection_unweighted(part_matroid))
def _repr_(self):
@@ -156,7 +156,7 @@ cdef class MatroidSum(Matroid):
E = set()
for i in range(len(self.summands)):
g = self.summands[i].groundset()
- E.update(zip([i]*len(g),g))
+ E.update(zip([i] * len(g), g))
self._groundset = frozenset(E)
def _repr_(self):
diff --git a/src/sage/meson.build b/src/sage/meson.build
index 80b2a030518..d0cf55161b9 100644
--- a/src/sage/meson.build
+++ b/src/sage/meson.build
@@ -86,6 +86,7 @@ foreach package : no_processing
endforeach
py.install_sources(
+ '__init__.py',
'all.py',
'all__sagemath_bliss.py',
'all__sagemath_categories.py',
diff --git a/src/sage/misc/cython.py b/src/sage/misc/cython.py
index c542e0d1919..adf2d8a10ef 100644
--- a/src/sage/misc/cython.py
+++ b/src/sage/misc/cython.py
@@ -226,17 +226,6 @@ def cython(filename, verbose=0, compile_message=False,
....: from sage.misc.cachefunc cimport cache_key
....: ''')
- In Cython 0.29.33 using `from PACKAGE cimport MODULE` is broken
- when `PACKAGE` is a namespace package, see :issue:`35322`::
-
- sage: cython('''
- ....: from sage.misc cimport cachefunc
- ....: ''')
- Traceback (most recent call last):
- ...
- RuntimeError: Error compiling Cython file:
- ...
- ...: 'sage/misc.pxd' not found
"""
if not filename.endswith('pyx'):
print("Warning: file (={}) should have extension .pyx".format(filename), file=sys.stderr)
@@ -380,7 +369,7 @@ def cython(filename, verbose=0, compile_message=False,
cython_messages = re.sub(
"^.*The keyword 'nogil' should appear at the end of the function signature line. "
"Placing it before 'except' or 'noexcept' will be disallowed in a future version of Cython.\n",
- "", cython_messages, 0, re.MULTILINE)
+ "", cython_messages, flags=re.MULTILINE)
sys.stderr.write(cython_messages)
sys.stderr.flush()
diff --git a/src/sage/misc/functional.py b/src/sage/misc/functional.py
index 7286501c0f1..fa8b7923d99 100644
--- a/src/sage/misc/functional.py
+++ b/src/sage/misc/functional.py
@@ -1137,6 +1137,13 @@ def log(*args, **kwds):
sage: log(0, 2)
-Infinity
+
+ Check if :issue:`37794` is fixed::
+
+ sage: log(int(0), 2)
+ -Infinity
+ sage: log(int(0), 1/2)
+ +Infinity
"""
base = kwds.pop('base', None)
if base:
diff --git a/src/sage/misc/meson.build b/src/sage/misc/meson.build
index f4ba17ef30a..97d4bf9e6a1 100644
--- a/src/sage/misc/meson.build
+++ b/src/sage/misc/meson.build
@@ -1,4 +1,5 @@
py.install_sources(
+ '__init__.py',
'abstract_method.py',
'all.py',
'all__sagemath_environment.py',
diff --git a/src/sage/modular/arithgroup/meson.build b/src/sage/modular/arithgroup/meson.build
index c4a68af3217..52475097b34 100644
--- a/src/sage/modular/arithgroup/meson.build
+++ b/src/sage/modular/arithgroup/meson.build
@@ -1,4 +1,5 @@
py.install_sources(
+ '__init__.py',
'all.py',
'arithgroup_generic.py',
'arithgroup_perm.py',
diff --git a/src/sage/modular/drinfeld_modform/ring.py b/src/sage/modular/drinfeld_modform/ring.py
index 43c41058fe2..b027edc08ca 100644
--- a/src/sage/modular/drinfeld_modform/ring.py
+++ b/src/sage/modular/drinfeld_modform/ring.py
@@ -36,7 +36,7 @@
from sage.rings.fraction_field import FractionField_generic
from sage.rings.polynomial.ore_polynomial_ring import OrePolynomialRing
from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing
-from sage.rings.polynomial.polynomial_ring import PolynomialRing_general
+from sage.rings.polynomial.polynomial_ring import PolynomialRing_generic
from sage.rings.polynomial.term_order import TermOrder
from sage.rings.integer_ring import ZZ
@@ -265,7 +265,7 @@ def __classcall_private__(cls, base_ring, rank=None, group=None,
if not isinstance(base_ring, FractionField_generic):
raise TypeError("base ring must be a fraction field of a "
"polynomial ring")
- if not isinstance(base_ring.base(), PolynomialRing_general):
+ if not isinstance(base_ring.base(), PolynomialRing_generic):
raise NotImplementedError("Drinfeld modular forms are currently "
"only implemented for A = Fq[T]")
if not base_ring.characteristic():
diff --git a/src/sage/modular/meson.build b/src/sage/modular/meson.build
index d334cf975c8..8b7e48c94aa 100644
--- a/src/sage/modular/meson.build
+++ b/src/sage/modular/meson.build
@@ -1,4 +1,5 @@
py.install_sources(
+ '__init__.py',
'all.py',
'buzzard.py',
'congroup.py',
diff --git a/src/sage/modular/modform/meson.build b/src/sage/modular/modform/meson.build
index 7276059448d..541227d9511 100644
--- a/src/sage/modular/modform/meson.build
+++ b/src/sage/modular/modform/meson.build
@@ -1,4 +1,5 @@
py.install_sources(
+ '__init__.py',
'all.py',
'ambient.py',
'ambient_R.py',
diff --git a/src/sage/modular/modform_hecketriangle/abstract_space.py b/src/sage/modular/modform_hecketriangle/abstract_space.py
index 79352b97ffe..8c9a5db1aac 100644
--- a/src/sage/modular/modform_hecketriangle/abstract_space.py
+++ b/src/sage/modular/modform_hecketriangle/abstract_space.py
@@ -23,7 +23,7 @@
from sage.rings.integer import Integer
from sage.rings.integer_ring import ZZ
from sage.rings.laurent_series_ring import LaurentSeriesRing
-from sage.rings.polynomial.polynomial_ring import PolynomialRing_general
+from sage.rings.polynomial.polynomial_ring import PolynomialRing_generic
from sage.rings.power_series_ring import PowerSeriesRing_generic
from sage.rings.rational_field import QQ
from sage.structure.element import parent
@@ -1707,7 +1707,7 @@ def construct_form(self, laurent_series, order_1=ZZ.zero(), check=True, rational
"""
base_ring = laurent_series.base_ring()
- if isinstance(base_ring.base(), PolynomialRing_general):
+ if isinstance(base_ring.base(), PolynomialRing_generic):
if not (self.coeff_ring().has_coerce_map_from(base_ring)):
raise ValueError("The Laurent coefficients don't coerce into the coefficient ring of self!")
elif rationalize:
@@ -2001,7 +2001,7 @@ def construct_quasi_form(self, laurent_series, order_1=ZZ.zero(), check=True, ra
"""
base_ring = laurent_series.base_ring()
- if isinstance(base_ring.base(), PolynomialRing_general):
+ if isinstance(base_ring.base(), PolynomialRing_generic):
if not (self.coeff_ring().has_coerce_map_from(base_ring)):
raise ValueError("The Laurent coefficients don't coerce into the coefficient ring of self!")
elif rationalize:
@@ -2269,7 +2269,7 @@ def rationalize_series(self, laurent_series, coeff_bound=1e-10, denom_factor=ZZ(
# If the coefficients already coerce to our coefficient ring
# and are in polynomial form we simply return the Laurent series
- if (isinstance(base_ring.base(), PolynomialRing_general)):
+ if (isinstance(base_ring.base(), PolynomialRing_generic)):
if (self.coeff_ring().has_coerce_map_from(base_ring)):
return laurent_series
else:
diff --git a/src/sage/modular/modform_hecketriangle/functors.py b/src/sage/modular/modform_hecketriangle/functors.py
index b50d618c3c4..20397eebfb5 100644
--- a/src/sage/modular/modform_hecketriangle/functors.py
+++ b/src/sage/modular/modform_hecketriangle/functors.py
@@ -79,7 +79,7 @@ def _get_base_ring(ring, var_name='d'):
"""
# from sage.rings.fraction_field import FractionField_generic
- from sage.rings.polynomial.polynomial_ring import PolynomialRing_general
+ from sage.rings.polynomial.polynomial_ring import PolynomialRing_generic
from sage.categories.pushout import FractionField as FractionFieldFunctor
base_ring = ring
@@ -87,7 +87,7 @@ def _get_base_ring(ring, var_name='d'):
# base_ring = base_ring.base()
if (base_ring.construction() and base_ring.construction()[0] == FractionFieldFunctor()):
base_ring = base_ring.construction()[1]
- if (isinstance(base_ring, PolynomialRing_general) and base_ring.ngens() == 1 and base_ring.variable_name() == var_name):
+ if (isinstance(base_ring, PolynomialRing_generic) and base_ring.ngens() == 1 and base_ring.variable_name() == var_name):
base_ring = base_ring.base()
if (base_ring.construction() and base_ring.construction()[0] == FractionFieldFunctor()):
base_ring = base_ring.construction()[1]
diff --git a/src/sage/modular/modsym/meson.build b/src/sage/modular/modsym/meson.build
index f05d0776246..15851710402 100644
--- a/src/sage/modular/modsym/meson.build
+++ b/src/sage/modular/modsym/meson.build
@@ -1,4 +1,5 @@
py.install_sources(
+ '__init__.py',
'all.py',
'ambient.py',
'apply.pxd',
diff --git a/src/sage/modular/pollack_stevens/distributions.py b/src/sage/modular/pollack_stevens/distributions.py
index 80bc25b22d9..cb387ebd8c1 100644
--- a/src/sage/modular/pollack_stevens/distributions.py
+++ b/src/sage/modular/pollack_stevens/distributions.py
@@ -39,6 +39,7 @@
# https://www.gnu.org/licenses/
# *************************************************************************
+from sage.categories.commutative_rings import CommutativeRings
from sage.categories.fields import Fields
from sage.categories.modules import Modules
from sage.misc.cachefunc import cached_method
@@ -46,7 +47,6 @@
from sage.modules.module import Module
from sage.rings.integer_ring import ZZ
from sage.rings.rational_field import QQ
-from sage.rings.ring import Ring
from sage.structure.factory import UniqueFactory
from sage.structure.parent import Parent
from .sigma0 import _default_adjuster
@@ -281,8 +281,8 @@ def __init__(self, k, p=None, prec_cap=None, base=None, character=None,
...
ValueError: p must be prime
"""
- if not isinstance(base, Ring):
- raise TypeError("base must be a ring")
+ if base not in CommutativeRings():
+ raise TypeError("base must be a commutative ring")
# from sage.rings.padics.pow_computer import PowComputer
# should eventually be the PowComputer on ZpCA once that uses longs.
Dist, WeightKAction = get_dist_classes(p, prec_cap, base,
@@ -649,10 +649,13 @@ def __init__(self, k, base, character, adjuster, act_on_left, dettwist,
if hasattr(base, 'prime'):
p = base.prime()
else:
- p = ZZ(0)
- OverconvergentDistributions_abstract.__init__(self, k, p, k + 1, base, character,
- adjuster, act_on_left, dettwist,
- act_padic, implementation)
+ p = ZZ.zero()
+ OverconvergentDistributions_abstract.__init__(self, k, p, k + 1,
+ base, character,
+ adjuster, act_on_left,
+ dettwist,
+ act_padic,
+ implementation)
def _an_element_(self):
r"""
diff --git a/src/sage/modular/pollack_stevens/meson.build b/src/sage/modular/pollack_stevens/meson.build
index d22947db12c..0506a90ac83 100644
--- a/src/sage/modular/pollack_stevens/meson.build
+++ b/src/sage/modular/pollack_stevens/meson.build
@@ -1,4 +1,5 @@
py.install_sources(
+ '__init__.py',
'all.py',
'dist.pxd',
'distributions.py',
diff --git a/src/sage/modules/fp_graded/all.py b/src/sage/modules/fp_graded/all.py
old mode 100755
new mode 100644
diff --git a/src/sage/modules/fp_graded/element.py b/src/sage/modules/fp_graded/element.py
old mode 100755
new mode 100644
diff --git a/src/sage/modules/fp_graded/free_element.py b/src/sage/modules/fp_graded/free_element.py
old mode 100755
new mode 100644
diff --git a/src/sage/modules/fp_graded/free_homspace.py b/src/sage/modules/fp_graded/free_homspace.py
old mode 100755
new mode 100644
diff --git a/src/sage/modules/fp_graded/free_module.py b/src/sage/modules/fp_graded/free_module.py
old mode 100755
new mode 100644
diff --git a/src/sage/modules/fp_graded/free_morphism.py b/src/sage/modules/fp_graded/free_morphism.py
old mode 100755
new mode 100644
diff --git a/src/sage/modules/fp_graded/homspace.py b/src/sage/modules/fp_graded/homspace.py
old mode 100755
new mode 100644
diff --git a/src/sage/modules/fp_graded/module.py b/src/sage/modules/fp_graded/module.py
old mode 100755
new mode 100644
diff --git a/src/sage/modules/fp_graded/morphism.py b/src/sage/modules/fp_graded/morphism.py
old mode 100755
new mode 100644
diff --git a/src/sage/modules/fp_graded/steenrod/all.py b/src/sage/modules/fp_graded/steenrod/all.py
old mode 100755
new mode 100644
diff --git a/src/sage/modules/fp_graded/steenrod/homspace.py b/src/sage/modules/fp_graded/steenrod/homspace.py
old mode 100755
new mode 100644
diff --git a/src/sage/modules/fp_graded/steenrod/module.py b/src/sage/modules/fp_graded/steenrod/module.py
old mode 100755
new mode 100644
diff --git a/src/sage/modules/fp_graded/steenrod/morphism.py b/src/sage/modules/fp_graded/steenrod/morphism.py
old mode 100755
new mode 100644
diff --git a/src/sage/modules/fp_graded/steenrod/profile.py b/src/sage/modules/fp_graded/steenrod/profile.py
old mode 100755
new mode 100644
diff --git a/src/sage/modules/meson.build b/src/sage/modules/meson.build
index 48aecfdf0f2..a5c78e98633 100644
--- a/src/sage/modules/meson.build
+++ b/src/sage/modules/meson.build
@@ -1,4 +1,5 @@
py.install_sources(
+ '__init__.py',
'all.py',
'complex_double_vector.py',
'diamond_cutting.py',
@@ -16,6 +17,7 @@ py.install_sources(
'module.pxd',
'module_functors.py',
'multi_filtered_vector_space.py',
+ 'numpy_util.pxd',
'quotient_module.py',
'real_double_vector.py',
'submodule.py',
diff --git a/src/sage/modules/with_basis/meson.build b/src/sage/modules/with_basis/meson.build
index 1956c6ac99c..7dc1dda551b 100644
--- a/src/sage/modules/with_basis/meson.build
+++ b/src/sage/modules/with_basis/meson.build
@@ -1,4 +1,5 @@
py.install_sources(
+ '__init__.py',
'all.py',
'cell_module.py',
'indexed_element.pxd',
diff --git a/src/sage/monoids/meson.build b/src/sage/monoids/meson.build
index df2a4ae36be..5f785b5b257 100644
--- a/src/sage/monoids/meson.build
+++ b/src/sage/monoids/meson.build
@@ -1,4 +1,5 @@
py.install_sources(
+ '__init__.py',
'all.py',
'automatic_semigroup.py',
'free_abelian_monoid.py',
diff --git a/src/sage/numerical/backends/glpk_backend.pyx b/src/sage/numerical/backends/glpk_backend.pyx
index 5e1f0dcdf82..6c6d8dfff90 100644
--- a/src/sage/numerical/backends/glpk_backend.pyx
+++ b/src/sage/numerical/backends/glpk_backend.pyx
@@ -3197,60 +3197,60 @@ solver_parameter_values = {
'intopt_only': intopt_only,
'exact_simplex_only': exact_simplex_only,
- 'GLP_MSG_OFF' : GLP_MSG_OFF,
- 'GLP_MSG_ON' : GLP_MSG_ON,
- 'GLP_MSG_ERR' : GLP_MSG_ERR,
- 'GLP_MSG_ALL' : GLP_MSG_ALL,
- 'GLP_MSG_DBG' : GLP_MSG_DBG,
-
- 'GLP_PRIMAL' : GLP_PRIMAL,
- 'GLP_DUAL' : GLP_DUAL,
- 'GLP_DUALP' : GLP_DUALP,
-
- 'GLP_PT_STD' : GLP_PT_STD,
- 'GLP_PT_PSE' : GLP_PT_PSE,
-
- 'GLP_RT_STD' : GLP_RT_STD,
- 'GLP_RT_HAR' : GLP_RT_HAR,
-
- 'DBL_MAX' : DBL_MAX,
- 'INT_MAX' : INT_MAX,
-
- 'GLP_ON' : GLP_ON,
- 'GLP_OFF' : GLP_OFF,
-
- 'GLP_BR_FFV' : GLP_BR_FFV,
- 'GLP_BR_LFV' : GLP_BR_LFV,
- 'GLP_BR_MFV' : GLP_BR_MFV,
- 'GLP_BR_DTH' : GLP_BR_DTH,
- 'GLP_BR_PCH' : GLP_BR_PCH,
-
- 'GLP_BT_DFS' : GLP_BT_DFS,
- 'GLP_BT_BFS' : GLP_BT_BFS,
- 'GLP_BT_BLB' : GLP_BT_BLB,
- 'GLP_BT_BPH' : GLP_BT_BPH,
-
- 'GLP_PP_NONE' : GLP_PP_NONE,
- 'GLP_PP_ROOT' : GLP_PP_ROOT,
- 'GLP_PP_ALL' : GLP_PP_ALL,
-
- 'GLP_MAX' : GLP_MAX,
- 'GLP_MIN' : GLP_MIN,
- 'GLP_UP' : GLP_UP,
- 'GLP_FR' : GLP_FR,
- 'GLP_DB' : GLP_DB,
- 'GLP_FX' : GLP_FX,
- 'GLP_LO' : GLP_LO,
- 'GLP_CV' : GLP_CV,
- 'GLP_IV' : GLP_IV,
- 'GLP_BV' : GLP_BV,
- 'GLP_MPS_DECK' : GLP_MPS_DECK,
- 'GLP_MPS_FILE' : GLP_MPS_FILE,
-
- 'GLP_UNDEF' : GLP_UNDEF,
- 'GLP_OPT' : GLP_OPT,
- 'GLP_FEAS' : GLP_FEAS,
- 'GLP_NOFEAS' : GLP_NOFEAS
+ 'GLP_MSG_OFF': GLP_MSG_OFF,
+ 'GLP_MSG_ON': GLP_MSG_ON,
+ 'GLP_MSG_ERR': GLP_MSG_ERR,
+ 'GLP_MSG_ALL': GLP_MSG_ALL,
+ 'GLP_MSG_DBG': GLP_MSG_DBG,
+
+ 'GLP_PRIMAL': GLP_PRIMAL,
+ 'GLP_DUAL': GLP_DUAL,
+ 'GLP_DUALP': GLP_DUALP,
+
+ 'GLP_PT_STD': GLP_PT_STD,
+ 'GLP_PT_PSE': GLP_PT_PSE,
+
+ 'GLP_RT_STD': GLP_RT_STD,
+ 'GLP_RT_HAR': GLP_RT_HAR,
+
+ 'DBL_MAX': DBL_MAX,
+ 'INT_MAX': INT_MAX,
+
+ 'GLP_ON': GLP_ON,
+ 'GLP_OFF': GLP_OFF,
+
+ 'GLP_BR_FFV': GLP_BR_FFV,
+ 'GLP_BR_LFV': GLP_BR_LFV,
+ 'GLP_BR_MFV': GLP_BR_MFV,
+ 'GLP_BR_DTH': GLP_BR_DTH,
+ 'GLP_BR_PCH': GLP_BR_PCH,
+
+ 'GLP_BT_DFS': GLP_BT_DFS,
+ 'GLP_BT_BFS': GLP_BT_BFS,
+ 'GLP_BT_BLB': GLP_BT_BLB,
+ 'GLP_BT_BPH': GLP_BT_BPH,
+
+ 'GLP_PP_NONE': GLP_PP_NONE,
+ 'GLP_PP_ROOT': GLP_PP_ROOT,
+ 'GLP_PP_ALL': GLP_PP_ALL,
+
+ 'GLP_MAX': GLP_MAX,
+ 'GLP_MIN': GLP_MIN,
+ 'GLP_UP': GLP_UP,
+ 'GLP_FR': GLP_FR,
+ 'GLP_DB': GLP_DB,
+ 'GLP_FX': GLP_FX,
+ 'GLP_LO': GLP_LO,
+ 'GLP_CV': GLP_CV,
+ 'GLP_IV': GLP_IV,
+ 'GLP_BV': GLP_BV,
+ 'GLP_MPS_DECK': GLP_MPS_DECK,
+ 'GLP_MPS_FILE': GLP_MPS_FILE,
+
+ 'GLP_UNDEF': GLP_UNDEF,
+ 'GLP_OPT': GLP_OPT,
+ 'GLP_FEAS': GLP_FEAS,
+ 'GLP_NOFEAS': GLP_NOFEAS
}
diff --git a/src/sage/numerical/backends/logging_backend.py b/src/sage/numerical/backends/logging_backend.py
index a7acf57341f..ae0c6b22d36 100644
--- a/src/sage/numerical/backends/logging_backend.py
+++ b/src/sage/numerical/backends/logging_backend.py
@@ -7,15 +7,15 @@
See :class:`LoggingBackendFactory` for more information.
"""
-#*****************************************************************************
+# ****************************************************************************
# Copyright (C) 2016 Matthias Koeppe
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
-# http://www.gnu.org/licenses/
-#*****************************************************************************
+# https://www.gnu.org/licenses/
+# ****************************************************************************
from sage.numerical.backends.generic_backend import GenericBackend
@@ -31,7 +31,7 @@ def _format_function_call(fn_name, *v, **k):
sage: _format_function_call('foo', 17, hellooooo='goodbyeeee')
"foo(17, hellooooo='goodbyeeee')"
"""
- args = [ repr(a) for a in v ] + [ "%s=%r" % (arg,val) for arg, val in k.items() ]
+ args = [repr(a) for a in v] + ["%s=%r" % (arg, val) for arg, val in k.items()]
return "{}({})".format(fn_name, ", ".join(args))
@@ -359,15 +359,15 @@ def LoggingBackendFactory(solver=None, printing=True, doctest_file=None, test_me
# Construct output file name from method name.
test_method_file = "test_{}.py".format(test_method)
else:
- test_method = 'CHANGE' # Will have to be edited by user in
- # generated file.
+ test_method = 'CHANGE'
+ # Will have to be edited by user in generated file.
if doctest_file is not None:
- doctest = open(doctest_file, "w", 1) #line-buffered
+ doctest = open(doctest_file, "w", 1) # line-buffered
else:
doctest = None
if test_method_file is not None:
- test_method_output = open(test_method_file, "w", 1) #line-buffered
+ test_method_output = open(test_method_file, "w", 1) # line-buffered
else:
test_method_output = None
diff --git a/src/sage/numerical/backends/meson.build b/src/sage/numerical/backends/meson.build
index a6a53e97033..57eeaeb10b0 100644
--- a/src/sage/numerical/backends/meson.build
+++ b/src/sage/numerical/backends/meson.build
@@ -2,6 +2,7 @@
glpk = cc.find_library('glpk')
py.install_sources(
+ '__init__.py',
'all.py',
'all__sagemath_polyhedra.py',
'cvxopt_backend_test.py',
diff --git a/src/sage/numerical/interactive_simplex_method.py b/src/sage/numerical/interactive_simplex_method.py
index 24dd0ded920..e394224a3c9 100644
--- a/src/sage/numerical/interactive_simplex_method.py
+++ b/src/sage/numerical/interactive_simplex_method.py
@@ -1538,7 +1538,7 @@ def plot(self, *args, **kwds):
result += line(level.vertices(), color='black',
linestyle='--')
result.set_axes_range(xmin, xmax, ymin, ymax)
- result.axes_labels(FP.axes_labels()) #FIXME: should be preserved!
+ result.axes_labels(FP.axes_labels()) # FIXME: should be preserved!
return result
def plot_feasible_set(self, xmin=None, xmax=None, ymin=None, ymax=None,
@@ -3933,7 +3933,7 @@ def _latex_(self):
lines.append(r"\renewcommand{\arraystretch}{1.5} %notruncate")
if generate_real_LaTeX:
lines[-1] += r" \setlength{\arraycolsep}{0.125em}"
- relations = [_latex_product(-Ai,N, head=[xi, "=", bi],
+ relations = [_latex_product(-Ai, N, head=[xi, "=", bi],
drop_plus=False, allow_empty=True) + r"\\"
for xi, bi, Ai in zip(B, b, A.rows())]
objective = _latex_product(c, N, head=[z, "=", v],
diff --git a/src/sage/numerical/meson.build b/src/sage/numerical/meson.build
index 222deff834e..91257af0880 100644
--- a/src/sage/numerical/meson.build
+++ b/src/sage/numerical/meson.build
@@ -1,4 +1,5 @@
py.install_sources(
+ '__init__.py',
'all.py',
'all__sagemath_polyhedra.py',
'interactive_simplex_method.py',
diff --git a/src/sage/plot/hyperbolic_regular_polygon.py b/src/sage/plot/hyperbolic_regular_polygon.py
index 14e8bdcaf68..a6df71ebc11 100644
--- a/src/sage/plot/hyperbolic_regular_polygon.py
+++ b/src/sage/plot/hyperbolic_regular_polygon.py
@@ -141,9 +141,9 @@ def __init__(self, sides, i_angle, center, options):
# real part of the given center.
h_disp = self.center.real()
- d_z_k = [z_0[0]*scale + h_disp] #d_k has the points for the polygon in the given center
- z_k = z_0 #z_k has the Re(z)>0 vertices for the I centered polygon
- r_z_k = [] #r_z_k has the Re(z)<0 vertices
+ d_z_k = [z_0[0]*scale + h_disp] # d_k has the points for the polygon in the given center
+ z_k = z_0 # z_k has the Re(z)>0 vertices for the I centered polygon
+ r_z_k = [] # r_z_k has the Re(z)<0 vertices
if is_odd(self.sides):
vert = (self.sides - 1) // 2
else:
diff --git a/src/sage/plot/meson.build b/src/sage/plot/meson.build
index 96a337faf78..8cb44114959 100644
--- a/src/sage/plot/meson.build
+++ b/src/sage/plot/meson.build
@@ -1,4 +1,5 @@
py.install_sources(
+ '__init__.py',
'all.py',
'animate.py',
'arc.py',
diff --git a/src/sage/plot/plot3d/meson.build b/src/sage/plot/plot3d/meson.build
index 46cc4a25ffc..ae1dd2a6b41 100644
--- a/src/sage/plot/plot3d/meson.build
+++ b/src/sage/plot/plot3d/meson.build
@@ -1,4 +1,5 @@
py.install_sources(
+ '__init__.py',
'all.py',
'base.pxd',
'implicit_plot3d.py',
diff --git a/src/sage/probability/meson.build b/src/sage/probability/meson.build
index 83b6a7e091e..2981a7496c4 100644
--- a/src/sage/probability/meson.build
+++ b/src/sage/probability/meson.build
@@ -1,4 +1,9 @@
-py.install_sources('all.py', 'random_variable.py', subdir: 'sage/probability')
+py.install_sources(
+ '__init__.py',
+ 'all.py',
+ 'random_variable.py',
+ subdir: 'sage/probability',
+)
extension_data = {
'probability_distribution' : files('probability_distribution.pyx'),
diff --git a/src/sage/quadratic_forms/binary_qf.py b/src/sage/quadratic_forms/binary_qf.py
old mode 100755
new mode 100644
diff --git a/src/sage/quadratic_forms/meson.build b/src/sage/quadratic_forms/meson.build
index 0e352ed72be..3208c9f15f6 100644
--- a/src/sage/quadratic_forms/meson.build
+++ b/src/sage/quadratic_forms/meson.build
@@ -1,4 +1,5 @@
py.install_sources(
+ '__init__.py',
'all.py',
'binary_qf.py',
'bqf_class_group.py',
diff --git a/src/sage/quivers/meson.build b/src/sage/quivers/meson.build
index cdefdce952b..aa6d757721d 100644
--- a/src/sage/quivers/meson.build
+++ b/src/sage/quivers/meson.build
@@ -1,4 +1,5 @@
py.install_sources(
+ '__init__.py',
'algebra.py',
'algebra_elements.pxd',
'all.py',
diff --git a/src/sage/rings/asymptotic/asymptotic_ring.py b/src/sage/rings/asymptotic/asymptotic_ring.py
index f7b8b6bb893..91a5775624e 100644
--- a/src/sage/rings/asymptotic/asymptotic_ring.py
+++ b/src/sage/rings/asymptotic/asymptotic_ring.py
@@ -428,7 +428,7 @@
lazy_import('sage.rings.lazy_series_ring', 'LazyPowerSeriesRing')
lazy_import('sage.rings.polynomial.multi_polynomial_ring_base', 'MPolynomialRing_base')
-lazy_import('sage.rings.polynomial.polynomial_ring', 'PolynomialRing_general')
+lazy_import('sage.rings.polynomial.polynomial_ring', 'PolynomialRing_generic')
lazy_import('sage.rings.power_series_ring', 'PowerSeriesRing_generic')
lazy_import('sage.symbolic.ring', 'SymbolicRing')
@@ -4013,7 +4013,7 @@ def _element_constructor_(self, data, simplify=True, convert=True):
(data, self)), e)
return sum(summands, self.zero())
- elif isinstance(P, PolynomialRing_general):
+ elif isinstance(P, PolynomialRing_generic):
p = P.gen()
try:
return sum(iter(self.create_summand('exact', growth=p**i,
diff --git a/src/sage/rings/asymptotic/asymptotics_multivariate_generating_functions.py b/src/sage/rings/asymptotic/asymptotics_multivariate_generating_functions.py
index 69ee6a36f6c..8603936d232 100644
--- a/src/sage/rings/asymptotic/asymptotics_multivariate_generating_functions.py
+++ b/src/sage/rings/asymptotic/asymptotics_multivariate_generating_functions.py
@@ -502,10 +502,10 @@ def dimension(self):
sage: F.dimension()
2
"""
- from sage.rings.polynomial.polynomial_ring import PolynomialRing_general
+ from sage.rings.polynomial.polynomial_ring import PolynomialRing_generic
from sage.rings.polynomial.multi_polynomial_ring_base import MPolynomialRing_base
R = self.denominator_ring
- if isinstance(R, (PolynomialRing_general, MPolynomialRing_base)):
+ if isinstance(R, (PolynomialRing_generic, MPolynomialRing_base)):
return R.ngens()
raise NotImplementedError('only polynomial rings are supported as base')
@@ -3165,9 +3165,9 @@ def _element_constructor_(self, *args, **kwargs):
p = numerator
q = R(denominator)
- from sage.rings.polynomial.polynomial_ring import PolynomialRing_general
+ from sage.rings.polynomial.polynomial_ring import PolynomialRing_generic
from sage.rings.polynomial.multi_polynomial_ring_base import MPolynomialRing_base
- if isinstance(R, (PolynomialRing_general, MPolynomialRing_base)):
+ if isinstance(R, (PolynomialRing_generic, MPolynomialRing_base)):
if not R(q).is_unit():
# Factor denominator
try:
@@ -3233,11 +3233,10 @@ def _coerce_map_from_(self, P):
from sage.rings.fraction_field import FractionField_generic
if isinstance(P, FractionField_generic):
B = P.base()
- from sage.rings.polynomial.polynomial_ring import PolynomialRing_general
+ from sage.rings.polynomial.polynomial_ring import PolynomialRing_generic
from sage.rings.polynomial.multi_polynomial_ring_base import MPolynomialRing_base
- if isinstance(B, (PolynomialRing_general, MPolynomialRing_base)):
- if self.base().has_coerce_map_from(B):
- return True
+ if isinstance(B, (PolynomialRing_generic, MPolynomialRing_base)) and self.base().has_coerce_map_from(B):
+ return True
if self.base().has_coerce_map_from(P):
return True
diff --git a/src/sage/rings/asymptotic/growth_group.py b/src/sage/rings/asymptotic/growth_group.py
index ca2afc2b92c..a82188ed355 100644
--- a/src/sage/rings/asymptotic/growth_group.py
+++ b/src/sage/rings/asymptotic/growth_group.py
@@ -1745,9 +1745,9 @@ def _initial_category_(base):
# The following block can be removed once #19269 is fixed.
from sage.rings.integer_ring import ZZ
from sage.rings.rational_field import QQ
- from sage.rings.polynomial.polynomial_ring import PolynomialRing_general
+ from sage.rings.polynomial.polynomial_ring import PolynomialRing_generic
if base is ZZ or base is QQ or \
- isinstance(base, PolynomialRing_general) and \
+ isinstance(base, PolynomialRing_generic) and \
(base.base_ring() is ZZ or base.base_ring() is QQ):
return Posets()
else:
@@ -3463,7 +3463,7 @@ def _convert_(self, data):
from sage.symbolic.ring import SR
return self._convert_(SR(data))
- from sage.rings.polynomial.polynomial_ring import PolynomialRing_general
+ from sage.rings.polynomial.polynomial_ring import PolynomialRing_generic
from sage.rings.polynomial.multi_polynomial_ring_base import \
MPolynomialRing_base
from sage.rings.power_series_ring import PowerSeriesRing_generic
@@ -3473,7 +3473,7 @@ def _convert_(self, data):
base, exponent = data.operands()
if str(base) == var:
return exponent
- elif isinstance(P, (PolynomialRing_general, MPolynomialRing_base)):
+ elif isinstance(P, (PolynomialRing_generic, MPolynomialRing_base)):
if data.is_monomial() and len(data.variables()) == 1:
if var == str(data.variables()[0]):
return data.degree()
diff --git a/src/sage/rings/asymptotic/misc.py b/src/sage/rings/asymptotic/misc.py
index e3d7a013285..740529a374e 100644
--- a/src/sage/rings/asymptotic/misc.py
+++ b/src/sage/rings/asymptotic/misc.py
@@ -34,7 +34,7 @@
lazy_import('sage.rings.lazy_series_ring', 'LazyPowerSeriesRing')
lazy_import('sage.rings.multi_power_series_ring', 'MPowerSeriesRing_generic')
lazy_import('sage.rings.polynomial.multi_polynomial_ring_base', 'MPolynomialRing_base')
-lazy_import('sage.rings.polynomial.polynomial_ring', 'PolynomialRing_general')
+lazy_import('sage.rings.polynomial.polynomial_ring', 'PolynomialRing_generic')
lazy_import('sage.rings.power_series_ring', 'PowerSeriesRing_generic')
@@ -168,7 +168,7 @@ def abbreviate(P):
pass
raise ValueError('Cannot abbreviate %s.' % (P,))
- poly = isinstance(P, (PolynomialRing_general, MPolynomialRing_base))
+ poly = isinstance(P, (PolynomialRing_generic, MPolynomialRing_base))
power = isinstance(P, (PowerSeriesRing_generic, MPowerSeriesRing_generic, LazyPowerSeriesRing))
if poly or power:
diff --git a/src/sage/rings/cfinite_sequence.py b/src/sage/rings/cfinite_sequence.py
index 4166083de4a..f0d1c22c147 100644
--- a/src/sage/rings/cfinite_sequence.py
+++ b/src/sage/rings/cfinite_sequence.py
@@ -95,7 +95,7 @@
from sage.rings.integer_ring import ZZ
from sage.rings.rational_field import QQ
from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing
-from sage.rings.polynomial.polynomial_ring import PolynomialRing_general
+from sage.rings.polynomial.polynomial_ring import PolynomialRing_generic
from sage.rings.laurent_series_ring import LaurentSeriesRing
from sage.rings.power_series_ring import PowerSeriesRing
from sage.rings.fraction_field import FractionField
@@ -142,7 +142,7 @@ def CFiniteSequences(base_ring, names=None, category=None):
sage: TestSuite(C).run()
"""
- if isinstance(base_ring, PolynomialRing_general):
+ if isinstance(base_ring, PolynomialRing_generic):
polynomial_ring = base_ring
base_ring = polynomial_ring.base_ring()
if names is None:
diff --git a/src/sage/rings/convert/meson.build b/src/sage/rings/convert/meson.build
index 0b485247bf1..04b9e285593 100644
--- a/src/sage/rings/convert/meson.build
+++ b/src/sage/rings/convert/meson.build
@@ -1,4 +1,9 @@
-py.install_sources('all.py', 'mpfi.pxd', subdir: 'sage/rings/convert')
+py.install_sources(
+ '__init__.py',
+ 'all.py',
+ 'mpfi.pxd',
+ subdir: 'sage/rings/convert',
+)
extension_data = {'mpfi' : files('mpfi.pyx')}
diff --git a/src/sage/rings/derivation.py b/src/sage/rings/derivation.py
index a1f80611473..4375ddfe656 100644
--- a/src/sage/rings/derivation.py
+++ b/src/sage/rings/derivation.py
@@ -193,7 +193,7 @@
from sage.structure.element import ModuleElement
from sage.rings.integer_ring import ZZ
-from sage.rings.polynomial.polynomial_ring import PolynomialRing_general
+from sage.rings.polynomial.polynomial_ring import PolynomialRing_generic
from sage.rings.polynomial.multi_polynomial_ring_base import MPolynomialRing_base
from sage.rings.power_series_ring import PowerSeriesRing_generic
from sage.rings.laurent_series_ring import LaurentSeriesRing
@@ -331,9 +331,9 @@ def __init__(self, domain, codomain, twist=None):
self._basis = [ ]
self._dual_basis = [ ]
self._constants = (domain, True)
- elif (isinstance(domain, (PolynomialRing_general, MPolynomialRing_base, PowerSeriesRing_generic, LaurentSeriesRing))
+ elif (isinstance(domain, (PolynomialRing_generic, MPolynomialRing_base, PowerSeriesRing_generic, LaurentSeriesRing))
or (isinstance(domain, FractionField_generic)
- and isinstance(domain.ring(), (PolynomialRing_general, MPolynomialRing_base)))):
+ and isinstance(domain.ring(), (PolynomialRing_generic, MPolynomialRing_base)))):
self._base_derivation = RingDerivationModule(domain.base_ring(), defining_morphism)
self.Element = RingDerivationWithoutTwist_function
try:
diff --git a/src/sage/rings/finite_rings/element_base.pyx b/src/sage/rings/finite_rings/element_base.pyx
old mode 100755
new mode 100644
diff --git a/src/sage/rings/finite_rings/meson.build b/src/sage/rings/finite_rings/meson.build
index 7f7a5744a1f..7e6c338636f 100644
--- a/src/sage/rings/finite_rings/meson.build
+++ b/src/sage/rings/finite_rings/meson.build
@@ -1,4 +1,5 @@
py.install_sources(
+ '__init__.py',
'all.py',
'conway_polynomials.py',
'element_base.pxd',
diff --git a/src/sage/rings/finite_rings/residue_field.pyx b/src/sage/rings/finite_rings/residue_field.pyx
index be83c5165f6..f6f8c08666f 100644
--- a/src/sage/rings/finite_rings/residue_field.pyx
+++ b/src/sage/rings/finite_rings/residue_field.pyx
@@ -189,7 +189,7 @@ from sage.rings.number_field.number_field_ideal import NumberFieldIdeal
from sage.rings.fraction_field import FractionField_generic
from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing
-from sage.rings.polynomial.polynomial_ring import PolynomialRing_general
+from sage.rings.polynomial.polynomial_ring import PolynomialRing_generic
from sage.rings.polynomial.polynomial_element import Polynomial
from sage.structure.element cimport Element, parent, Vector
@@ -337,7 +337,7 @@ class ResidueFieldFactory(UniqueFactory):
raise ValueError("p must be an ideal or element of a number field or function field.")
if not p.is_prime():
raise ValueError("p (%s) must be prime" % p)
- if isinstance(p.ring(), PolynomialRing_general):
+ if isinstance(p.ring(), PolynomialRing_generic):
if not p.ring().base_ring().is_finite():
raise ValueError("residue fields only supported for polynomial rings over finite fields")
if not p.ring().base_ring().is_prime_field():
@@ -373,7 +373,7 @@ class ResidueFieldFactory(UniqueFactory):
if pring is ZZ:
return ResidueFiniteField_prime_modn(p, names, p.gen(), None, None, None)
- if isinstance(pring, PolynomialRing_general):
+ if isinstance(pring, PolynomialRing_generic):
K = pring.fraction_field()
Kbase = pring.base_ring()
f = p.gen()
@@ -1400,7 +1400,7 @@ cdef class ResidueFieldHomomorphism_global(RingHomomorphism):
# No special code for residue fields of Z, since we just use the normal reduction map to GF(p)
if self._K is ZZ:
return self._F(x)
- if isinstance(self._K, PolynomialRing_general):
+ if isinstance(self._K, PolynomialRing_generic):
p = self._F.p.gen()
if p.degree() == 1:
return self._F((x % p)[0])
@@ -1658,7 +1658,7 @@ cdef class LiftingMap(Section):
return self._K(self._K.ring_of_integers()(x))
else:
return self._K(self._K.ring_of_integers()(x.polynomial().list()))
- elif isinstance(self._K, PolynomialRing_general):
+ elif isinstance(self._K, PolynomialRing_generic):
return self._K(x.polynomial().list())
# Else the lifting map is just x |--> to_order(x * PB)
x = self._F(x)
diff --git a/src/sage/rings/function_field/drinfeld_modules/drinfeld_module.py b/src/sage/rings/function_field/drinfeld_modules/drinfeld_module.py
index e29626593b4..0b8d4cd32ff 100644
--- a/src/sage/rings/function_field/drinfeld_modules/drinfeld_module.py
+++ b/src/sage/rings/function_field/drinfeld_modules/drinfeld_module.py
@@ -38,7 +38,7 @@
from sage.rings.integer import Integer
from sage.rings.integer_ring import ZZ
from sage.rings.polynomial.ore_polynomial_element import OrePolynomial
-from sage.rings.polynomial.polynomial_ring import PolynomialRing_general
+from sage.rings.polynomial.polynomial_ring import PolynomialRing_generic
from sage.structure.parent import Parent
from sage.structure.sage_object import SageObject
from sage.structure.sequence import Sequence
@@ -564,7 +564,7 @@ def __classcall_private__(cls, function_ring, gen, name='t'):
# duplicate. As a general comment, there are sanity checks both
# here and in the category constructor, which is not ideal.
# Check domain is Fq[T]
- if not isinstance(function_ring, PolynomialRing_general):
+ if not isinstance(function_ring, PolynomialRing_generic):
raise NotImplementedError('function ring must be a polynomial '
'ring')
function_ring_base = function_ring.base_ring()
diff --git a/src/sage/rings/function_field/khuri_makdisi.pyx b/src/sage/rings/function_field/khuri_makdisi.pyx
index aa64322b0ed..d32677bed6f 100644
--- a/src/sage/rings/function_field/khuri_makdisi.pyx
+++ b/src/sage/rings/function_field/khuri_makdisi.pyx
@@ -871,13 +871,31 @@ cdef class KhuriMakdisi_small(KhuriMakdisi_base):
sage: p2 = G.point(pl2 - b)
sage: -(-p1) == p1 # indirect doctest
True
+
+ Check that :issue:`39148` is fixed::
+
+ sage: # long time
+ sage: k. = FunctionField(GF(17)); t = polygen(k)
+ sage: F. = k.extension(t^4 + (14*x + 14)*t^3 + 9*t^2 + (10*x^2 + 15*x + 8)*t
+ ....: + 7*x^3 + 15*x^2 + 6*x + 16)
+ sage: infty1, infty2 = F.places_infinite()
+ sage: O = F.maximal_order()
+ sage: P = O.ideal((x + 1, y + 7)).divisor()
+ sage: D1 = 3*infty2 + infty1 - 4*P
+ sage: D2 = F.divisor_group().zero()
+ sage: J = F.jacobian(model='km-small', base_div=4*P)
+ sage: J(D1) + J(D2) == J(D1)
+ True
"""
cdef int d0 = self.d0
cdef int g = self.g
cdef Matrix w1, w2, w3, w4
w1 = self.mu_image(self.wV2, wd, self.mu_mat23, 4*d0 - g + 1)
- w2 = self.mu_preimage(self.wV3, w1, self.mu_mat23, d0)
+ # The row space of w2 represents H^0(O(2D_0 - D)), whose dimension is
+ # at least d0 - g + 1, and hence the codimension is at most d0. Thus,
+ # we cannot provide an expected_codim argument for mu_preimage.
+ w2 = self.mu_preimage(self.wV3, w1, self.mu_mat23)
# efficient than
# wf = matrix(w2[0])
# w3 = self.mu_image(wf, self.wV4, self.mu_mat24, 4*d0 - g + 1)
diff --git a/src/sage/rings/function_field/meson.build b/src/sage/rings/function_field/meson.build
index 16e5fa6fa6f..0ed61989167 100644
--- a/src/sage/rings/function_field/meson.build
+++ b/src/sage/rings/function_field/meson.build
@@ -1,4 +1,5 @@
py.install_sources(
+ '__init__.py',
'all.py',
'constructor.py',
'derivations.py',
diff --git a/src/sage/rings/laurent_series_ring.py b/src/sage/rings/laurent_series_ring.py
index 2142f717460..1feba6e675b 100644
--- a/src/sage/rings/laurent_series_ring.py
+++ b/src/sage/rings/laurent_series_ring.py
@@ -52,7 +52,7 @@
lazy_import('sage.rings.polynomial.laurent_polynomial_ring_base', 'LaurentPolynomialRing_generic')
lazy_import('sage.rings.lazy_series_ring', ('LazyPowerSeriesRing', 'LazyLaurentSeriesRing'))
-lazy_import('sage.rings.polynomial.polynomial_ring', 'PolynomialRing_general')
+lazy_import('sage.rings.polynomial.polynomial_ring', 'PolynomialRing_generic')
lazy_import('sage.rings.power_series_ring', 'PowerSeriesRing_generic')
@@ -691,7 +691,7 @@ def _coerce_map_from_(self, P):
if (isinstance(P, (LaurentSeriesRing, LazyLaurentSeriesRing,
LaurentPolynomialRing_generic,
PowerSeriesRing_generic, LazyPowerSeriesRing,
- PolynomialRing_general))
+ PolynomialRing_generic))
and P.variable_name() == self.variable_name()
and A.has_coerce_map_from(P.base_ring())):
return True
diff --git a/src/sage/rings/lazy_series.py b/src/sage/rings/lazy_series.py
index b48e0e6bc38..b670cce965c 100644
--- a/src/sage/rings/lazy_series.py
+++ b/src/sage/rings/lazy_series.py
@@ -4203,8 +4203,8 @@ def __call__(self, g):
if not isinstance(g, LazyModuleElement):
# Check to see if it belongs to a polynomial ring
# that we can extend to a lazy series ring
- from sage.rings.polynomial.polynomial_ring import PolynomialRing_general
- if isinstance(P, PolynomialRing_general):
+ from sage.rings.polynomial.polynomial_ring import PolynomialRing_generic
+ if isinstance(P, PolynomialRing_generic):
from sage.rings.lazy_series_ring import LazyLaurentSeriesRing
R = LazyLaurentSeriesRing(P.base_ring(), P.variable_names(), P.is_sparse())
g = R(P(g))
@@ -5203,7 +5203,7 @@ def __call__(self, *g):
# f now has (potentially) infinitely many terms
# Lift the resulting parent to a lazy series (if possible)
# Also make sure each element of g is a LazyModuleElement
- from sage.rings.polynomial.polynomial_ring import PolynomialRing_general
+ from sage.rings.polynomial.polynomial_ring import PolynomialRing_generic
from sage.rings.polynomial.multi_polynomial_ring_base import MPolynomialRing_base
from sage.rings.polynomial.laurent_polynomial_ring import LaurentPolynomialRing_univariate
from sage.rings.lazy_series_ring import LazySeriesRing
@@ -5211,7 +5211,7 @@ def __call__(self, *g):
if fP._laurent_poly_ring.has_coerce_map_from(P):
S = fP._laurent_poly_ring
P = fP
- if isinstance(P, (PolynomialRing_general, MPolynomialRing_base)):
+ if isinstance(P, (PolynomialRing_generic, MPolynomialRing_base)):
from sage.rings.lazy_series_ring import LazyPowerSeriesRing
S = P
try:
diff --git a/src/sage/rings/meson.build b/src/sage/rings/meson.build
index 171592eccbd..a3be9efe30b 100644
--- a/src/sage/rings/meson.build
+++ b/src/sage/rings/meson.build
@@ -1,4 +1,5 @@
py.install_sources(
+ '__init__.py',
'abc.pxd',
'algebraic_closure_finite_field.py',
'all.py',
diff --git a/src/sage/rings/morphism.pyx b/src/sage/rings/morphism.pyx
index 3079bfa3974..791e8b70b93 100644
--- a/src/sage/rings/morphism.pyx
+++ b/src/sage/rings/morphism.pyx
@@ -1036,7 +1036,7 @@ cdef class RingHomomorphism(RingMap):
from sage.rings.polynomial.polynomial_quotient_ring import PolynomialQuotientRing_generic
from sage.rings.quotient_ring import QuotientRing_nc
from sage.rings.polynomial.multi_polynomial_ring import MPolynomialRing_base
- from sage.rings.polynomial.polynomial_ring import PolynomialRing_general
+ from sage.rings.polynomial.polynomial_ring import PolynomialRing_generic
B = self.codomain()
graph, from_B, to_A = self._graph_ideal()
Q = graph.ring()
@@ -1045,7 +1045,7 @@ cdef class RingHomomorphism(RingMap):
# avoid adding the 0-ideal to the graph ideal in order to benefit
# from a cached Gröbner basis
graph_I = graph
- elif (isinstance(B, MPolynomialRing_base) or isinstance(B, PolynomialRing_general)
+ elif (isinstance(B, MPolynomialRing_base) or isinstance(B, PolynomialRing_generic)
or isinstance(B, QuotientRing_nc) or isinstance(B, PolynomialQuotientRing_generic)):
graph_I = graph + from_B(I)
else:
@@ -3137,7 +3137,7 @@ def _tensor_product_ring(B, A):
from sage.rings.number_field.number_field_base import NumberField
from sage.rings.polynomial.multi_polynomial_ring import MPolynomialRing_base
from sage.rings.polynomial.polynomial_quotient_ring import PolynomialQuotientRing_generic
- from sage.rings.polynomial.polynomial_ring import PolynomialRing_general
+ from sage.rings.polynomial.polynomial_ring import PolynomialRing_generic
from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing
from sage.rings.polynomial.term_order import TermOrder
from sage.rings.quotient_ring import QuotientRing_nc
@@ -3150,7 +3150,7 @@ def _tensor_product_ring(B, A):
def term_order(A):
# univariate rings do not have a term order
- if (isinstance(A, PolynomialRing_general) or isinstance(A, PolynomialQuotientRing_generic)
+ if (isinstance(A, (PolynomialRing_generic, PolynomialQuotientRing_generic))
or (isinstance(A, (NumberField, FiniteField))
and not A.is_prime_field())):
return TermOrder('lex', 1)
@@ -3166,7 +3166,7 @@ def _tensor_product_ring(B, A):
order=term_order(B) + term_order(A))
def relations(A, R_gens_A):
- if isinstance(A, MPolynomialRing_base) or isinstance(A, PolynomialRing_general):
+ if isinstance(A, (MPolynomialRing_base, PolynomialRing_generic)):
return []
elif isinstance(A, PolynomialQuotientRing_generic):
to_R = A.ambient().hom(R_gens_A, R, check=False)
diff --git a/src/sage/rings/multi_power_series_ring.py b/src/sage/rings/multi_power_series_ring.py
index 3a30b89b9e9..43f446a7e09 100644
--- a/src/sage/rings/multi_power_series_ring.py
+++ b/src/sage/rings/multi_power_series_ring.py
@@ -208,7 +208,7 @@
from sage.misc.lazy_import import lazy_import
from sage.rings.infinity import infinity
from sage.rings.multi_power_series_ring_element import MPowerSeries
-from sage.rings.polynomial.polynomial_ring import PolynomialRing_general
+from sage.rings.polynomial.polynomial_ring import PolynomialRing_generic
from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing
from sage.rings.polynomial.multi_polynomial_ring import MPolynomialRing_base
from sage.rings.polynomial.term_order import TermOrder
@@ -674,7 +674,7 @@ def _coerce_impl(self, f):
True
"""
P = f.parent()
- if isinstance(P, (PolynomialRing_general, MPolynomialRing_base,
+ if isinstance(P, (PolynomialRing_generic, MPolynomialRing_base,
PowerSeriesRing_generic, MPowerSeriesRing_generic,
LazyPowerSeriesRing)):
if set(P.variable_names()).issubset(set(self.variable_names())):
@@ -841,7 +841,7 @@ def _coerce_map_from_(self, P):
True
"""
if isinstance(P, (MPolynomialRing_base, MPowerSeriesRing_generic, LazyPowerSeriesRing,
- PolynomialRing_general, PowerSeriesRing_generic)):
+ PolynomialRing_generic, PowerSeriesRing_generic)):
if set(P.variable_names()).issubset(set(self.variable_names())):
if self.has_coerce_map_from(P.base_ring()):
return True
diff --git a/src/sage/rings/multi_power_series_ring_element.py b/src/sage/rings/multi_power_series_ring_element.py
index 046f8338e05..5f8bba84c49 100644
--- a/src/sage/rings/multi_power_series_ring_element.py
+++ b/src/sage/rings/multi_power_series_ring_element.py
@@ -158,7 +158,7 @@
from sage.rings.finite_rings.integer_mod_ring import Zmod
from sage.rings.infinity import infinity, InfinityElement
from sage.rings.integer import Integer
-from sage.rings.polynomial.polynomial_ring import PolynomialRing_general
+from sage.rings.polynomial.polynomial_ring import PolynomialRing_generic
from sage.rings.power_series_ring_element import PowerSeries
from sage.structure.richcmp import richcmp
@@ -406,7 +406,7 @@ def __init__(self, parent, x=0, prec=infinity, is_gen=False, check=False):
self._bg_value = parent._send_to_bg(x).add_bigoh(prec)
# test whether x coerces to underlying polynomial ring of parent
- elif isinstance(xparent, PolynomialRing_general):
+ elif isinstance(xparent, PolynomialRing_generic):
self._bg_value = parent._send_to_bg(x).add_bigoh(prec)
else:
diff --git a/src/sage/rings/number_field/meson.build b/src/sage/rings/number_field/meson.build
index 46162077eb8..5b612679d40 100644
--- a/src/sage/rings/number_field/meson.build
+++ b/src/sage/rings/number_field/meson.build
@@ -1,5 +1,6 @@
py.install_sources(
'S_unit_solver.py',
+ '__init__.py',
'all.py',
'bdd_height.py',
'class_group.py',
diff --git a/src/sage/rings/number_field/number_field.py b/src/sage/rings/number_field/number_field.py
index 2559771ae62..dbd8e7e2edf 100644
--- a/src/sage/rings/number_field/number_field.py
+++ b/src/sage/rings/number_field/number_field.py
@@ -75,10 +75,12 @@
# https://www.gnu.org/licenses/
# ****************************************************************************
from __future__ import annotations
+from itertools import count
+from collections import Counter
+
from sage.misc.cachefunc import cached_method
from sage.misc.superseded import deprecation
-
import sage.libs.ntl.all as ntl
import sage.rings.abc
import sage.rings.complex_mpfr
@@ -99,7 +101,6 @@
from sage.rings.finite_rings.integer_mod import mod
from sage.categories.number_fields import NumberFields
-from sage.rings.ring import Ring
from sage.misc.latex import latex_variable_name
from .unit_group import UnitGroup
@@ -118,8 +119,6 @@
from . import maps
from . import structure
from . import number_field_morphisms
-from itertools import count
-from collections import Counter
from sage.categories.homset import Hom
from sage.categories.sets_cat import Sets
@@ -128,6 +127,7 @@
from sage.rings.real_mpfr import RR
from sage.interfaces.abc import GapElement
+from sage.rings.number_field.morphism import RelativeNumberFieldHomomorphism_from_abs
lazy_import('sage.libs.gap.element', 'GapElement', as_='LibGapElement')
lazy_import('sage.rings.universal_cyclotomic_field', 'UniversalCyclotomicFieldElement')
@@ -136,13 +136,12 @@
_NumberFields = NumberFields()
-from sage.rings.number_field.morphism import RelativeNumberFieldHomomorphism_from_abs
-
-
def is_NumberFieldHomsetCodomain(codomain):
"""
Return whether ``codomain`` is a valid codomain for a number
- field homset. This is used by NumberField._Hom_ to determine
+ field homset.
+
+ This is used by NumberField._Hom_ to determine
whether the created homsets should be a
:class:`sage.rings.number_field.homset.NumberFieldHomset`.
@@ -414,8 +413,8 @@ def NumberField(polynomial, name=None, check=True, names=None, embedding=None,
sage: RR(g)
-1.25992104989487
- If no embedding is specified or is complex, the comparison is not returning something
- meaningful.::
+ If no embedding is specified or is complex, the comparison is not
+ returning something meaningful. ::
sage: N. = NumberField(x^3 + 2)
sage: 1 < g
diff --git a/src/sage/rings/number_field/number_field_ideal.py b/src/sage/rings/number_field/number_field_ideal.py
index 3686840ccba..171fba9af6e 100644
--- a/src/sage/rings/number_field/number_field_ideal.py
+++ b/src/sage/rings/number_field/number_field_ideal.py
@@ -2170,17 +2170,18 @@ def reduce(self, f):
M = MatrixSpace(ZZ,n)([R.coordinates(y) for y in self.basis()])
D = M.hermite_form()
- d = [D[i,i] for i in range(n)]
+ d = [D[i, i] for i in range(n)]
v = R.coordinates(f)
for i in range(n):
- q, r = ZZ(v[i]).quo_rem(d[i])#v is a vector of rationals, we want division of integers
+ q, r = ZZ(v[i]).quo_rem(d[i])
+ # v is a vector of rationals, we want division of integers
if 2*r > d[i]:
q = q + 1
v = v - q*D[i]
- return sum([v[i]*Rbasis[i] for i in range(n)])
+ return sum([v[i] * Rbasis[i] for i in range(n)])
def residues(self):
r"""
diff --git a/src/sage/rings/padics/factory.py b/src/sage/rings/padics/factory.py
index 44093d2cf67..a0990ad1720 100644
--- a/src/sage/rings/padics/factory.py
+++ b/src/sage/rings/padics/factory.py
@@ -3548,7 +3548,7 @@ def krasner_check(poly, prec):
sage: krasner_check(1,2) # this is a stupid example.
True
"""
- return True #This needs to be implemented
+ return True # This needs to be implemented
def is_eisenstein(poly):
diff --git a/src/sage/rings/padics/generic_nodes.py b/src/sage/rings/padics/generic_nodes.py
index 27ca55b274f..5b8c7468c75 100644
--- a/src/sage/rings/padics/generic_nodes.py
+++ b/src/sage/rings/padics/generic_nodes.py
@@ -257,7 +257,7 @@ def _test_additive_associativity(self, **options):
tester = self._tester(**options)
S = tester.some_elements()
from sage.misc.misc import some_tuples
- for x,y,z in some_tuples(S, 3, tester._max_runs):
+ for x, y, z in some_tuples(S, 3, tester._max_runs):
tester.assertTrue(((x + y) + z).is_equal_to(x + (y + z), min(x.precision_absolute(), y.precision_absolute(), z.precision_absolute())))
@@ -265,7 +265,8 @@ class FloatingPointRingGeneric(FloatingPointGeneric):
pass
-class FloatingPointFieldGeneric(FloatingPointGeneric):#, sage.rings.ring.Field):
+class FloatingPointFieldGeneric(FloatingPointGeneric):
+ # in category of Fields()
pass
@@ -273,7 +274,8 @@ class CappedRelativeRingGeneric(CappedRelativeGeneric):
pass
-class CappedRelativeFieldGeneric(CappedRelativeGeneric):#, sage.rings.ring.Field):
+class CappedRelativeFieldGeneric(CappedRelativeGeneric):
+ # in category of Fields()
pass
diff --git a/src/sage/rings/padics/meson.build b/src/sage/rings/padics/meson.build
index 9cb64492095..f589881042e 100644
--- a/src/sage/rings/padics/meson.build
+++ b/src/sage/rings/padics/meson.build
@@ -1,4 +1,5 @@
py.install_sources(
+ '__init__.py',
'all.py',
'common_conversion.pxd',
'eisenstein_extension_generic.py',
diff --git a/src/sage/rings/padics/padic_valuation.py b/src/sage/rings/padics/padic_valuation.py
index 1050055e1fb..3d150562508 100644
--- a/src/sage/rings/padics/padic_valuation.py
+++ b/src/sage/rings/padics/padic_valuation.py
@@ -554,8 +554,8 @@ def is_unramified(self, G, include_steps=False, assume_squarefree=False):
"""
R = G.parent()
- from sage.rings.polynomial.polynomial_ring import PolynomialRing_general
- if not isinstance(R, PolynomialRing_general) or R.base_ring() is not self.domain() or not G.is_monic():
+ from sage.rings.polynomial.polynomial_ring import PolynomialRing_generic
+ if not isinstance(R, PolynomialRing_generic) or R.base_ring() is not self.domain() or not G.is_monic():
raise ValueError("G must be a monic univariate polynomial over the domain of this valuation")
if not assume_squarefree and not G.is_squarefree():
raise ValueError("G must be squarefree")
@@ -651,8 +651,8 @@ def is_totally_ramified(self, G, include_steps=False, assume_squarefree=False):
"""
R = G.parent()
- from sage.rings.polynomial.polynomial_ring import PolynomialRing_general
- if not isinstance(R, PolynomialRing_general) or R.base_ring() is not self.domain() or not G.is_monic():
+ from sage.rings.polynomial.polynomial_ring import PolynomialRing_generic
+ if not isinstance(R, PolynomialRing_generic) or R.base_ring() is not self.domain() or not G.is_monic():
raise ValueError("G must be a monic univariate polynomial over the domain of this valuation")
if not assume_squarefree and not G.is_squarefree():
raise ValueError("G must be squarefree")
diff --git a/src/sage/rings/padics/relative_extension_leaves.py b/src/sage/rings/padics/relative_extension_leaves.py
index 3005ae0825b..b88aebf129a 100644
--- a/src/sage/rings/padics/relative_extension_leaves.py
+++ b/src/sage/rings/padics/relative_extension_leaves.py
@@ -378,7 +378,7 @@ def __init__(self, exact_modulus, approx_modulus, prec, print_mode, shift_seed,
"""
self._exact_modulus = exact_modulus
unram_prec = (prec + approx_modulus.degree() - 1) // approx_modulus.degree()
- KFP = approx_modulus.base_ring()#.change(field=False, show_prec=False)
+ KFP = approx_modulus.base_ring() # .change(field=False, show_prec=False)
self.prime_pow = PowComputer_relative_maker(approx_modulus.base_ring().prime(), max(min(unram_prec - 1, 30), 1), unram_prec, prec, False, exact_modulus.change_ring(KFP), shift_seed.change_ring(KFP), 'floating-point')
self._implementation = 'Polynomial'
EisensteinExtensionGeneric.__init__(self, approx_modulus, prec, print_mode, names, RelativeRamifiedFloatingPointElement)
@@ -416,7 +416,7 @@ def __init__(self, exact_modulus, approx_modulus, prec, print_mode, shift_seed,
"""
self._exact_modulus = exact_modulus
unram_prec = (prec + approx_modulus.degree() - 1) // approx_modulus.degree()
- KFP = approx_modulus.base_ring()#.change(field=False, show_prec=False)
+ KFP = approx_modulus.base_ring() # .change(field=False, show_prec=False)
self.prime_pow = PowComputer_relative_maker(approx_modulus.base_ring().prime(), max(min(unram_prec - 1, 30), 1), unram_prec, prec, True, exact_modulus.change_ring(KFP), shift_seed.change_ring(KFP), 'floating-point')
self._implementation = 'Polynomial'
EisensteinExtensionGeneric.__init__(self, approx_modulus, prec, print_mode, names, RelativeRamifiedFloatingPointElement)
diff --git a/src/sage/rings/polynomial/cyclotomic.pyx b/src/sage/rings/polynomial/cyclotomic.pyx
index 8c9088434fa..e9eb5675b90 100644
--- a/src/sage/rings/polynomial/cyclotomic.pyx
+++ b/src/sage/rings/polynomial/cyclotomic.pyx
@@ -4,7 +4,7 @@ Fast calculation of cyclotomic polynomials
This module provides a function :func:`cyclotomic_coeffs`, which calculates the
coefficients of cyclotomic polynomials. This is not intended to be invoked
directly by the user, but it is called by the method
-:meth:`~sage.rings.polynomial.polynomial_ring.PolynomialRing_general.cyclotomic_polynomial`
+:meth:`~sage.rings.polynomial.polynomial_ring.PolynomialRing_generic.cyclotomic_polynomial`
method of univariate polynomial ring objects and the top-level
:func:`~sage.misc.functional.cyclotomic_polynomial` function.
"""
diff --git a/src/sage/rings/polynomial/flatten.py b/src/sage/rings/polynomial/flatten.py
index 32d07423e91..174c1d7b1bd 100644
--- a/src/sage/rings/polynomial/flatten.py
+++ b/src/sage/rings/polynomial/flatten.py
@@ -38,7 +38,7 @@
from sage.categories.morphism import Morphism
from sage.misc.cachefunc import cached_method
from .polynomial_ring_constructor import PolynomialRing
-from .polynomial_ring import PolynomialRing_general
+from .polynomial_ring import PolynomialRing_generic
from .multi_polynomial_ring_base import MPolynomialRing_base
from sage.rings.fraction_field import FractionField_generic
from sage.rings.fraction_field_element import FractionFieldElement
@@ -160,14 +160,14 @@ def __init__(self, domain):
sage: fl.section()(fl(p)) == p
True
"""
- if not isinstance(domain, PolynomialRing_general) and not isinstance(domain, MPolynomialRing_base):
+ if not isinstance(domain, (PolynomialRing_generic, MPolynomialRing_base)):
raise ValueError("domain should be a polynomial ring")
ring = domain
variables = []
intermediate_rings = []
- while isinstance(ring, (PolynomialRing_general, MPolynomialRing_base)):
+ while isinstance(ring, (PolynomialRing_generic, MPolynomialRing_base)):
intermediate_rings.append(ring)
v = ring.variable_names()
variables.extend(reversed(v))
@@ -221,7 +221,7 @@ def _call_(self, p):
for ring in self._intermediate_rings:
new_p = {}
- if isinstance(ring, PolynomialRing_general):
+ if isinstance(ring, PolynomialRing_generic):
for mon, pp in p.items():
assert pp.parent() is ring
for i, j in pp.monomial_coefficients().items():
@@ -347,14 +347,14 @@ def __init__(self, domain, codomain):
"""
if not isinstance(domain, MPolynomialRing_base):
raise ValueError("domain should be a multivariate polynomial ring")
- if not isinstance(codomain, PolynomialRing_general) and not isinstance(codomain, MPolynomialRing_base):
+ if not isinstance(codomain, (PolynomialRing_generic, MPolynomialRing_base)):
raise ValueError("codomain should be a polynomial ring")
ring = codomain
intermediate_rings = []
while True:
- is_polynomial_ring = isinstance(ring, PolynomialRing_general)
+ is_polynomial_ring = isinstance(ring, PolynomialRing_generic)
if not (is_polynomial_ring or isinstance(ring, MPolynomialRing_base)):
break
intermediate_rings.append((ring, is_polynomial_ring))
@@ -499,7 +499,7 @@ def __init__(self, domain, D):
Defn: Defined on coordinates by sending (z) to
(z^2 + 1.00000000000000)
"""
- if not isinstance(domain, PolynomialRing_general) and not isinstance(domain, MPolynomialRing_base):
+ if not isinstance(domain, (PolynomialRing_generic, MPolynomialRing_base)):
raise TypeError("domain should be a polynomial ring")
# use only the generators that are in the stack somewhere,
@@ -538,7 +538,7 @@ def __init__(self, domain, D):
# Construct unflattened codomain R
new_vars = []
R = domain
- while isinstance(R, (PolynomialRing_general,
+ while isinstance(R, (PolynomialRing_generic,
MPolynomialRing_base,
FractionField_generic)):
if isinstance(R, FractionField_generic):
diff --git a/src/sage/rings/polynomial/laurent_polynomial.pyx b/src/sage/rings/polynomial/laurent_polynomial.pyx
index 0fed2467c05..cdd459c8218 100644
--- a/src/sage/rings/polynomial/laurent_polynomial.pyx
+++ b/src/sage/rings/polynomial/laurent_polynomial.pyx
@@ -13,7 +13,7 @@ from sage.structure.element import coerce_binop, parent
from sage.structure.factorization import Factorization
from sage.misc.derivative import multi_derivative
from sage.rings.polynomial.polynomial_element import Polynomial
-from sage.rings.polynomial.polynomial_ring import PolynomialRing_general
+from sage.rings.polynomial.polynomial_ring import PolynomialRing_generic
from sage.structure.richcmp cimport richcmp, rich_to_bool
from sage.rings.infinity import minus_infinity
@@ -429,7 +429,7 @@ cdef class LaurentPolynomial_univariate(LaurentPolynomial):
if self.__n < 0:
raise ValueError("Laurent polynomial with negative valuation cannot be converted to polynomial")
- if isinstance(R, PolynomialRing_general):
+ if isinstance(R, PolynomialRing_generic):
return R(self.__u) << self.__n
elif self.__n == 0:
return R(self.__u)
diff --git a/src/sage/rings/polynomial/laurent_polynomial_ring.py b/src/sage/rings/polynomial/laurent_polynomial_ring.py
index 2e4cf5ce6ea..0e48259a531 100644
--- a/src/sage/rings/polynomial/laurent_polynomial_ring.py
+++ b/src/sage/rings/polynomial/laurent_polynomial_ring.py
@@ -236,14 +236,14 @@ def LaurentPolynomialRing(base_ring, *args, **kwds):
sage: (w0 + 2*w8 + w13)^2 # needs sage.modules
w0^2 + 4*w0*w8 + 4*w8^2 + 2*w0*w13 + 4*w8*w13 + w13^2
"""
- from sage.rings.polynomial.polynomial_ring import PolynomialRing_general
+ from sage.rings.polynomial.polynomial_ring import PolynomialRing_generic
from sage.rings.polynomial.multi_polynomial_ring_base import MPolynomialRing_base
R = PolynomialRing(base_ring, *args, **kwds)
if R in _cache:
return _cache[R] # put () here to re-enable weakrefs
- if isinstance(R, PolynomialRing_general):
+ if isinstance(R, PolynomialRing_generic):
# univariate case
P = LaurentPolynomialRing_univariate(R)
else:
diff --git a/src/sage/rings/polynomial/meson.build b/src/sage/rings/polynomial/meson.build
index cbd48976335..a74efed061a 100644
--- a/src/sage/rings/polynomial/meson.build
+++ b/src/sage/rings/polynomial/meson.build
@@ -1,4 +1,5 @@
py.install_sources(
+ '__init__.py',
'all.py',
'binary_form_reduce.py',
'commutative_polynomial.pxd',
diff --git a/src/sage/rings/polynomial/multi_polynomial_element.py b/src/sage/rings/polynomial/multi_polynomial_element.py
index a22330ef4b8..3b18664f505 100644
--- a/src/sage/rings/polynomial/multi_polynomial_element.py
+++ b/src/sage/rings/polynomial/multi_polynomial_element.py
@@ -636,12 +636,12 @@ def degree(self, x=None, std_grading=False):
sage: GF(3037000453)['x','y'].gen(0).degree(x0) # needs sage.rings.finite_rings
Traceback (most recent call last):
...
- TypeError: x must canonically coerce to parent
+ TypeError: argument is not coercible to the parent
sage: GF(3037000453)['x','y'].gen(0).degree(x^2) # needs sage.rings.finite_rings
Traceback (most recent call last):
...
- TypeError: x must be one of the generators of the parent
+ TypeError: argument is not a generator
TESTS::
@@ -817,7 +817,7 @@ def monomial_coefficients(self, copy=None):
``dict`` is an alias::
- sage: f.dict() # needs sage.rings.number_field
+ sage: f.dict() # needs sage.rings.number_field
{(1, 5, 2): 1, (2, 0, 1): 1, (4, 1, 3): 1}
"""
return self.element().dict()
diff --git a/src/sage/rings/polynomial/multi_polynomial_ideal.py b/src/sage/rings/polynomial/multi_polynomial_ideal.py
index 8db6eb03ea6..adf1dc5db01 100644
--- a/src/sage/rings/polynomial/multi_polynomial_ideal.py
+++ b/src/sage/rings/polynomial/multi_polynomial_ideal.py
@@ -601,10 +601,10 @@ def _groebner_cover(self):
"""
from sage.rings.fraction_field import FractionField_generic
from sage.rings.polynomial.multi_polynomial_ring_base import MPolynomialRing_base
- from sage.rings.polynomial.polynomial_ring import PolynomialRing_general
+ from sage.rings.polynomial.polynomial_ring import PolynomialRing_generic
F = self.base_ring()
if (not isinstance(F, FractionField_generic) or
- not isinstance(F.ring(), (MPolynomialRing_base, PolynomialRing_general))):
+ not isinstance(F.ring(), (MPolynomialRing_base, PolynomialRing_generic))):
raise TypeError("the base ring must be a field with parameters")
from sage.arith.functions import lcm
from sage.libs.singular.function import lib, singular_function
@@ -4528,8 +4528,7 @@ def groebner_basis(self, algorithm='', deg_bound=None, mult_bound=None, prot=Fal
sage: R. = PolynomialRing(Zmod(2233497349584))
sage: I = R.ideal([z*(x-3*y), 3^2*x^2-y*z, z^2+y^2])
sage: I.groebner_basis()
- [2*z^4, y*z^2 + 81*z^3, 248166372176*z^3, 9*x^2 - y*z, y^2 + z^2, x*z +
- 2233497349581*y*z, 248166372176*y*z]
+ [2*z^4, y*z^2 + 81*z^3, 248166372176*z^3, 9*x^2 + 2233497349583*y*z, y^2 + z^2, x*z + 2233497349581*y*z, 248166372176*y*z]
Sage also supports local orderings::
diff --git a/src/sage/rings/polynomial/multi_polynomial_libsingular.pyx b/src/sage/rings/polynomial/multi_polynomial_libsingular.pyx
index 9c940755987..d86aba9170c 100644
--- a/src/sage/rings/polynomial/multi_polynomial_libsingular.pyx
+++ b/src/sage/rings/polynomial/multi_polynomial_libsingular.pyx
@@ -65,7 +65,7 @@ We show how to construct various multivariate polynomial rings::
sage: P. = Zmod(25213521351515232)[]; P
Multivariate Polynomial Ring in x, y, z over Ring of integers modulo 25213521351515232
sage: type(P)
-
+
We construct the Frobenius morphism on `\GF{5}[x,y,z]` over `\GF{5}`::
@@ -170,6 +170,8 @@ AUTHORS:
# * pNext and pIter don't need currRing
# * p_Normalize apparently needs currRing
+from warnings import warn
+
from cpython.object cimport Py_NE
from cysignals.memory cimport sig_malloc, sig_free
from cysignals.signals cimport sig_on, sig_off
@@ -183,7 +185,6 @@ from sage.libs.singular.decl cimport (ring, poly, ideal, intvec, number,
# singular functions
from sage.libs.singular.decl cimport (
- errorreported,
n_Invers, n_GetChar,
p_ISet, rChangeCurrRing, p_Copy, p_Init, p_SetCoeff, p_Setm, p_SetExp, p_Add_q,
p_NSet, p_GetCoeff, p_Delete, p_GetExp, pNext, rRingVar, omAlloc0, omStrDup,
@@ -198,7 +199,7 @@ from sage.libs.singular.decl cimport (
prCopyR, prCopyR_NoSort)
# singular conversion routines
-from sage.libs.singular.singular cimport si2sa, sa2si, overflow_check
+from sage.libs.singular.singular cimport si2sa, sa2si, overflow_check, start_catch_error, check_error
# singular poly arith
from sage.libs.singular.polynomial cimport (
@@ -212,13 +213,15 @@ from sage.libs.singular.polynomial cimport (
# singular rings
from sage.libs.singular.ring cimport singular_ring_new, singular_ring_reference, singular_ring_delete
+from sage.rings.finite_rings.finite_field_prime_modn import FiniteField_prime_modn
+
# polynomial imports
from sage.rings.polynomial.multi_polynomial_ring import MPolynomialRing_polydict, MPolynomialRing_polydict_domain
from sage.rings.polynomial.multi_polynomial_ring_base import BooleanPolynomialRing_base
from sage.rings.polynomial.multi_polynomial_element import MPolynomial_polydict
from sage.rings.polynomial.multi_polynomial_ideal import MPolynomialIdeal
from sage.rings.polynomial.polydict cimport ETuple
-from sage.rings.polynomial.polynomial_ring import PolynomialRing_general
+from sage.rings.polynomial.polynomial_ring import PolynomialRing_generic
# base ring imports
import sage.rings.abc
@@ -340,11 +343,11 @@ cdef class MPolynomialRing_libsingular(MPolynomialRing_base):
Multivariate Polynomial Ring in x, y, z over
Ring of integers modulo 25213521351515232
sage: type(P)
-
+
sage: P. = PolynomialRing(Integers(2^32), order='lex')
sage: P(2^32-1)
- 4294967295
+ -1
TESTS:
@@ -508,7 +511,7 @@ cdef class MPolynomialRing_libsingular(MPolynomialRing_base):
return True
elif base_ring.has_coerce_map_from(other._mpoly_base_ring(self.variable_names())):
return True
- elif isinstance(other, PolynomialRing_general):
+ elif isinstance(other, PolynomialRing_generic):
if base_ring.has_coerce_map_from(other._mpoly_base_ring(self.variable_names())):
return True
@@ -4151,6 +4154,37 @@ cdef class MPolynomial_libsingular(MPolynomial_libsingular_base):
True
sage: p*q//p == q
True
+
+ Test many base rings::
+
+ sage: R. = GF(2^32+15)[]
+ sage: ((x+y)^3+x+z)//(x+y)
+ Traceback (most recent call last):
+ ...
+ NotImplementedError: Division of multivariate polynomials over non fields by non-monomials not implemented.
+ sage: R. = Zmod(2^29-3)[]
+ sage: ((x+y)^3+x+z)//(x+y)
+ Traceback (most recent call last):
+ ...
+ NotImplementedError: Division of multivariate polynomials over non fields by non-monomials not implemented.
+ sage: R. = GF(2^29+11)[]
+ sage: ((x+y)^3+x+z)//(x+y)
+ Traceback (most recent call last):
+ ...
+ NotImplementedError: Division of multivariate polynomials over prime fields with characteristic > 2^29 is not implemented.
+ sage: R. = Zmod(2^29+10)[]
+ sage: ((x+y)^3+x+z)//(x+y)
+ Traceback (most recent call last):
+ ...
+ NotImplementedError: Division of multivariate polynomials over prime fields with characteristic > 2^29 is not implemented.
+ sage: R. = GF((2^29-3)^2)[]
+ sage: ((x+y)^3+x+z)//(x+y)
+ x^2 + 2*x*y + y^2
+ sage: R. = Zmod(7^2)[]
+ sage: ((x+y)^3+x+z)//(x+y)
+ Traceback (most recent call last):
+ ...
+ NotImplementedError: Division of multivariate polynomials over non fields by non-monomials not implemented.
"""
cdef MPolynomialRing_libsingular parent = self._parent
cdef MPolynomial_libsingular _right = right
@@ -4461,12 +4495,58 @@ cdef class MPolynomial_libsingular(MPolynomial_libsingular_base):
sage: N = -a^4*z^8 + 2*a^2*b^2*z^8 - b^4*z^8 - 16*a^3*b*z^7 + 16*a*b^3*z^7 + 28*a^4*z^6 - 56*a^2*b^2*z^6 + 28*b^4*z^6 + 112*a^3*b*z^5 - 112*a*b^3*z^5 - 70*a^4*z^4 + 140*a^2*b^2*z^4 - 70*b^4*z^4 - 112*a^3*b*z^3 + 112*a*b^3*z^3 + 28*a^4*z^2 - 56*a^2*b^2*z^2 + 28*b^4*z^2 + 16*a^3*b*z - 16*a*b^3*z - a^4 + 2*a^2*b^2 - b^4
sage: N.factor()
(-1) * (-a + b) * (a + b) * (-z^4*a + z^4*b - 4*z^3*a - 4*z^3*b + 6*z^2*a - 6*z^2*b + 4*z*a + 4*z*b - a + b) * (z^4*a + z^4*b - 4*z^3*a + 4*z^3*b - 6*z^2*a - 6*z^2*b + 4*z*a - 4*z*b + a + b)
+
+ Test many base rings::
+
+ sage: R. = GF(2^32+15)[]
+ sage: ((x+y)^2*(x+z)^3).factor()
+ Traceback (most recent call last):
+ ...
+ NotImplementedError: Factorization of multivariate polynomials over prime fields with characteristic > 2^29 is not implemented.
+ sage: R. = Zmod(2^29-3)[]
+ sage: ((x+y)^2*(x+z)^3).factor()
+ (x + y)^2 * (x + z)^3
+ sage: R. = GF(2^29+11)[]
+ sage: ((x+y)^2*(x+z)^3).factor()
+ Traceback (most recent call last):
+ ...
+ NotImplementedError: Factorization of multivariate polynomials over prime fields with characteristic > 2^29 is not implemented.
+ sage: R. = Zmod(2^29+10)[]
+ sage: ((x+y)^2*(x+z)^3).factor()
+ Traceback (most recent call last):
+ ...
+ NotImplementedError: Factorization of multivariate polynomials over Ring of integers modulo 536870922 is not implemented.
+ sage: R. = GF((2^29-3)^2)[]
+ sage: ((x+y)^2*(x+z)^3).factor()
+ (x + y)^2 * (x + z)^3
+ sage: R. = Zmod(7^2)[]
+ sage: ((x+y)^2*(x+z)^3).factor()
+ Traceback (most recent call last):
+ ...
+ NotImplementedError: Factorization of multivariate polynomials over Ring of integers modulo 49 is not implemented.
+
+ Ensure interrupt does not make the internal state inconsistent::
+
+ sage: R. = QQ[]
+ sage: n = 11 # chosen so that the computation takes > 1 second but not excessively long.
+ ....: # when Singular improves the algorithm or hardware gets faster, increase n.
+ sage: alarm(0.5); h = (x^2^n-y^2^n).factor()
+ Traceback (most recent call last):
+ ...
+ AlarmInterrupt
+ sage: alarm(0.5); h = (x^2^n-y^2^n).factor()
+ Traceback (most recent call last):
+ ...
+ AlarmInterrupt
+ sage: h = (x^2^n-y^2^n).factor()
+ sage: h
+ (x - y) * (x + y) * (x^2 + y^2) * (x^4 + y^4) * (x^8 + y^8) * (x^16 + y^16) * (x^32 + y^32) * (x^64 + y^64) * (x^128 + y^128) * (x^256 + y^256) * (x^512 + y^512) * (x^1024 + y^1024)
"""
cdef ring *_ring = self._parent_ring
cdef poly *ptemp
cdef intvec *iv
cdef int *ivv
- cdef ideal *I
+ cdef ideal *I = NULL
cdef MPolynomialRing_libsingular parent = self._parent
cdef int i
@@ -4485,31 +4565,31 @@ cdef class MPolynomial_libsingular(MPolynomial_libsingular_base):
except Exception:
raise NotImplementedError("Factorization of multivariate polynomials over %s is not implemented."%self._parent._base)
- if n_GetChar(_ring.cf) > 1<<29:
- raise NotImplementedError("Factorization of multivariate polynomials over prime fields with characteristic > 2^29 is not implemented.")
-
- # I make a temporary copy of the poly in self because singclap_factorize appears to modify it's parameter
- ptemp = p_Copy(self._poly, _ring)
iv = NULL
- sig_on()
if _ring != currRing:
rChangeCurrRing(_ring) # singclap_factorize
- I = singclap_factorize(ptemp, &iv, 0, _ring)
- sig_off()
-
- ivv = iv.ivGetVec()
- v = [(new_MP(parent, p_Copy(I.m[i], _ring)), ivv[i])
- for i in range(1, I.ncols)]
- v = [(f, m) for f, m in v if f != 0] # we might have zero in there
- unit = new_MP(parent, p_Copy(I.m[0], _ring))
-
- F = Factorization(v, unit)
- F.sort()
-
- del iv
- id_Delete(&I, _ring)
-
- return F
+ start_catch_error()
+ try:
+ try:
+ sig_on()
+ I = singclap_factorize(p_Copy(self._poly, _ring), &iv, 0, _ring)
+ sig_off()
+ finally:
+ if check_error():
+ raise NotImplementedError("Factorization of multivariate polynomials over prime fields with characteristic > 2^29 is not implemented.")
+
+ ivv = iv.ivGetVec()
+ v = [(new_MP(parent, p_Copy(I.m[i], _ring)), ivv[i])
+ for i in range(1, I.ncols)]
+ v = [(f, m) for f, m in v if f != 0] # we might have zero in there
+ unit = new_MP(parent, p_Copy(I.m[0], _ring))
+
+ F = Factorization(v, unit)
+ F.sort()
+ return F
+ finally:
+ del iv
+ id_Delete(&I, _ring)
def lift(self, I):
"""
@@ -4559,7 +4639,6 @@ cdef class MPolynomial_libsingular(MPolynomial_libsingular_base):
sage: M
[y^7, x^7*y^2 + x^8 + x^5*y^3 + x^6*y + x^3*y^4 + x^4*y^2 + x*y^5 + x^2*y^3 + y^4]
-
TESTS:
Check that :issue:`13714` is fixed::
@@ -4573,16 +4652,32 @@ cdef class MPolynomial_libsingular(MPolynomial_libsingular_base):
sage: foo = I.complete_primary_decomposition() # indirect doctest
sage: foo[0][0]
Ideal (x1 + 1, x2^2 - 3) of Multivariate Polynomial Ring in x1, x2 over Rational Field
- """
- global errorreported
+ Ensure interrupt does not make the internal state inconsistent::
+
+ sage: R. = QQ[]
+ sage: n = 17 # chosen so that the computation takes > 1 second but not excessively long.
+ ....: # when Singular improves the algorithm or hardware gets faster, increase n.
+ sage: I = R.ideal([(x-i)*(y-j) for i in (0..n) for j in (0..n)])
+ sage: f = prod((x-i)*(y-j) for i in (0..n) for j in (0..n))
+ sage: alarm(0.5); f.lift(I)
+ Traceback (most recent call last):
+ ...
+ AlarmInterrupt
+ sage: alarm(0.5); f.lift(I)
+ Traceback (most recent call last):
+ ...
+ AlarmInterrupt
+ sage: f.lift(I)
+ Polynomial Sequence with 324 Polynomials in 2 Variables
+ """
cdef ideal *fI = idInit(1, 1)
cdef ideal *_I
cdef MPolynomialRing_libsingular parent = self._parent
cdef int i = 0
cdef int j
cdef ring *r = self._parent_ring
- cdef ideal *res
+ cdef ideal *res = NULL
if isinstance(I, MPolynomialIdeal):
I = I.gens()
@@ -4606,24 +4701,25 @@ cdef class MPolynomial_libsingular(MPolynomial_libsingular_base):
if r != currRing:
rChangeCurrRing(r) # idLift
- sig_on()
- res = idLift(_I, fI, NULL, 0, 0, 0)
- sig_off()
- if errorreported != 0:
- errorcode = errorreported
- errorreported = 0
- if errorcode == 1:
+ try:
+ start_catch_error()
+ try:
+ sig_on()
+ res = idLift(_I, fI, NULL, 0, 0, 0)
+ sig_off()
+ finally:
+ s = check_error()
+ if s:
+ if s != ('2nd module does not lie in the first',):
+ warn(f'unexpected error from singular: {s}')
raise ValueError("polynomial is not in the ideal")
- raise RuntimeError
-
- l = []
- for i from 0 <= i < IDELEMS(res):
- for j from 1 <= j <= IDELEMS(_I):
- l.append( new_MP(parent, pTakeOutComp(&res.m[i], 1)) )
- id_Delete(&fI, r)
- id_Delete(&_I, r)
- id_Delete(&res, r)
+ l = [new_MP(parent, pTakeOutComp(&res.m[i], 1))
+ for i in range(IDELEMS(res)) for _ in range(IDELEMS(_I))]
+ finally:
+ id_Delete(&fI, r)
+ id_Delete(&_I, r)
+ id_Delete(&res, r)
return Sequence(l, check=False, immutable=True)
def reduce(self, I):
@@ -4731,7 +4827,8 @@ cdef class MPolynomial_libsingular(MPolynomial_libsingular_base):
id_Delete(&_I,r)
return new_MP(parent,res)
- def divides(self, other):
+ @coerce_binop
+ def divides(self, MPolynomial_libsingular other):
"""
Return ``True`` if this polynomial divides ``other``.
@@ -4763,27 +4860,21 @@ cdef class MPolynomial_libsingular(MPolynomial_libsingular_base):
rChangeCurrRing(r)
_I = idInit(1, 1)
- if not (isinstance(other,MPolynomial_libsingular)
- and (other)._parent is parent):
- try:
- other = parent.coerce(other)
- except TypeError as msg:
- id_Delete(&_I,r)
- raise TypeError(msg)
-
_I.m[0] = p_Copy(self._poly, r)
if r != currRing:
rChangeCurrRing(r)
- sig_on()
- rem = kNF(_I, NULL, (other)._poly, 0, 1)
- sig_off()
- id_Delete(&_I, r)
+ try:
+ sig_on()
+ rem = kNF(_I, NULL, other._poly, 0, 1)
+ sig_off()
+ finally:
+ id_Delete(&_I, r)
res = new_MP(parent, rem).is_zero()
return res
@coerce_binop
- def gcd(self, right, algorithm=None, **kwds):
+ def gcd(self, MPolynomial_libsingular right, algorithm=None, **kwds):
"""
Return the greatest common divisor of ``self`` and ``right``.
@@ -4858,10 +4949,40 @@ cdef class MPolynomial_libsingular(MPolynomial_libsingular_base):
sage: q = -3*x^2*y^7*z + 2*x*y^6*z^3 + 2*x^2*y^3*z^4 + x^2*y^5 - 7*x*y^5*z
sage: (21^3*p^2*q).gcd(35^2*p*q^2) == -49*p*q
True
+
+ Test many base rings::
+
+ sage: R. = GF(2^32+15)[]
+ sage: ((x+y)^2*(x+z)^3).gcd((x+y)^3*(y+z)^5)
+ Traceback (most recent call last):
+ ...
+ NotImplementedError: GCD over rings not implemented.
+ sage: R. = Zmod(2^29-3)[]
+ sage: ((x+y)^2*(x+z)^3).gcd((x+y)^3*(y+z)^5)
+ Traceback (most recent call last):
+ ...
+ NotImplementedError: GCD over rings not implemented.
+ sage: R. = GF(2^29+11)[]
+ sage: ((x+y)^2*(x+z)^3).gcd((x+y)^3*(y+z)^5)
+ Traceback (most recent call last):
+ ...
+ NotImplementedError: GCD of multivariate polynomials over prime fields with characteristic > 2^29 is not implemented.
+ sage: R. = Zmod(2^29+10)[]
+ sage: ((x+y)^2*(x+z)^3).gcd((x+y)^3*(y+z)^5)
+ Traceback (most recent call last):
+ ...
+ NotImplementedError: GCD over rings not implemented.
+ sage: R. = GF((2^29-3)^2)[]
+ sage: ((x+y)^2*(x+z)^3).gcd((x+y)^3*(y+z)^5)
+ x^2 + 2*x*y + y^2
+ sage: R. = Zmod(7^2)[]
+ sage: ((x+y)^2*(x+z)^3).gcd((x+y)^3*(y+z)^5)
+ Traceback (most recent call last):
+ ...
+ NotImplementedError: GCD over rings not implemented.
"""
cdef poly *_res
cdef ring *_ring = self._parent_ring
- cdef MPolynomial_libsingular _right = right
if algorithm is None or algorithm == "modular":
On(SW_USE_CHINREM_GCD)
@@ -4872,13 +4993,13 @@ cdef class MPolynomial_libsingular(MPolynomial_libsingular_base):
else:
raise TypeError("algorithm %s not supported" % algorithm)
- if _right._poly == NULL:
+ if right._poly == NULL:
return self
elif self._poly == NULL:
return right
elif p_IsOne(self._poly, _ring):
return self
- elif p_IsOne(_right._poly, _ring):
+ elif p_IsOne(right._poly, _ring):
return right
if _ring.cf.type != n_unknown:
@@ -4889,10 +5010,10 @@ cdef class MPolynomial_libsingular(MPolynomial_libsingular_base):
raise NotImplementedError("GCD of multivariate polynomials over prime fields with characteristic > 2^29 is not implemented.")
cdef int count = singular_polynomial_length_bounded(self._poly, 20) \
- + singular_polynomial_length_bounded(_right._poly,20)
+ + singular_polynomial_length_bounded(right._poly, 20)
if count >= 20:
sig_on()
- _res = singclap_gcd(p_Copy(self._poly, _ring), p_Copy(_right._poly, _ring), _ring )
+ _res = singclap_gcd(p_Copy(self._poly, _ring), p_Copy(right._poly, _ring), _ring)
if count >= 20:
sig_off()
@@ -4944,6 +5065,37 @@ cdef class MPolynomial_libsingular(MPolynomial_libsingular_base):
2*x*y
sage: lcm(2*x, 2*x*y)
2*x*y
+
+ Test many base rings::
+
+ sage: R. = GF(2^32+15)[]
+ sage: ((x+y)^2*(x+z)^3).lcm((x+y)^3*(y+z)^5)
+ Traceback (most recent call last):
+ ...
+ TypeError: LCM over non-integral domains not available.
+ sage: R. = Zmod(2^29-3)[]
+ sage: ((x+y)^2*(x+z)^3).lcm((x+y)^3*(y+z)^5)
+ Traceback (most recent call last):
+ ...
+ TypeError: LCM over non-integral domains not available.
+ sage: R. = GF(2^29+11)[]
+ sage: ((x+y)^2*(x+z)^3).lcm((x+y)^3*(y+z)^5)
+ Traceback (most recent call last):
+ ...
+ NotImplementedError: LCM of multivariate polynomials over prime fields with characteristic > 2^29 is not implemented.
+ sage: R. = Zmod(2^29+10)[]
+ sage: ((x+y)^2*(x+z)^3).lcm((x+y)^3*(y+z)^5)
+ Traceback (most recent call last):
+ ...
+ TypeError: LCM over non-integral domains not available.
+ sage: R. = GF((2^29-3)^2)[]
+ sage: ((x+y)^2*(x+z)^3).lcm((x+y)^3*(y+z)^5)
+ x^6*y^5 + 3*x^5*y^6 + 3*x^4*y^7 + x^3*y^8 + 5*x^6*y^4*z + 18*x^5*y^5*z + 24*x^4*y^6*z + 14*x^3*y^7*z + 3*x^2*y^8*z + 10*x^6*y^3*z^2 + 45*x^5*y^4*z^2 + 78*x^4*y^5*z^2 + 64*x^3*y^6*z^2 + 24*x^2*y^7*z^2 + 3*x*y^8*z^2 + 10*x^6*y^2*z^3 + 60*x^5*y^3*z^3 + 135*x^4*y^4*z^3 + 146*x^3*y^5*z^3 + 78*x^2*y^6*z^3 + 18*x*y^7*z^3 + y^8*z^3 + 5*x^6*y*z^4 + 45*x^5*y^2*z^4 + 135*x^4*y^3*z^4 + 190*x^3*y^4*z^4 + 135*x^2*y^5*z^4 + 45*x*y^6*z^4 + 5*y^7*z^4 + x^6*z^5 + 18*x^5*y*z^5 + 78*x^4*y^2*z^5 + 146*x^3*y^3*z^5 + 135*x^2*y^4*z^5 + 60*x*y^5*z^5 + 10*y^6*z^5 + 3*x^5*z^6 + 24*x^4*y*z^6 + 64*x^3*y^2*z^6 + 78*x^2*y^3*z^6 + 45*x*y^4*z^6 + 10*y^5*z^6 + 3*x^4*z^7 + 14*x^3*y*z^7 + 24*x^2*y^2*z^7 + 18*x*y^3*z^7 + 5*y^4*z^7 + x^3*z^8 + 3*x^2*y*z^8 + 3*x*y^2*z^8 + y^3*z^8
+ sage: R. = Zmod(7^2)[]
+ sage: ((x+y)^2*(x+z)^3).lcm((x+y)^3*(y+z)^5)
+ Traceback (most recent call last):
+ ...
+ TypeError: LCM over non-integral domains not available.
"""
cdef ring *_ring = self._parent_ring
cdef poly *ret
@@ -5026,6 +5178,56 @@ cdef class MPolynomial_libsingular(MPolynomial_libsingular_base):
Traceback (most recent call last):
...
ZeroDivisionError
+
+ Test many base rings::
+
+ sage: R. = GF(2^32+15)[]
+ sage: ((x+y)^3+x+z).quo_rem(x+y)
+ Traceback (most recent call last):
+ ...
+ NotImplementedError: Division of multivariate polynomials over prime fields with characteristic > 2^29 is not implemented.
+ sage: R. = Zmod(2^29-3)[]
+ sage: ((x+y)^3+x+z).quo_rem(x+y)
+ (x^2 + 2*x*y + y^2, x + z)
+ sage: R. = GF(2^29+11)[]
+ sage: ((x+y)^3+x+z).quo_rem(x+y)
+ Traceback (most recent call last):
+ ...
+ NotImplementedError: Division of multivariate polynomials over prime fields with characteristic > 2^29 is not implemented.
+ sage: R. = Zmod(2^29+10)[]
+ sage: ((x+y)^3+x+z).quo_rem(x+y)
+ Traceback (most recent call last):
+ ...
+ NotImplementedError: Division of multivariate polynomials over prime fields with characteristic > 2^29 is not implemented.
+ sage: R. = GF((2^29-3)^2)[]
+ sage: ((x+y)^3+x+z).quo_rem(x+y)
+ (x^2 + 2*x*y + y^2, x + z)
+ sage: R. = Zmod(7^2)[]
+ sage: ((x+y)^3+x+z).quo_rem(x+y)
+ Traceback (most recent call last):
+ ...
+ NotImplementedError: Division of multivariate polynomials over non fields by non-monomials not implemented.
+
+ Ensure interrupt does not make the internal state inconsistent::
+
+ sage: R. = PolynomialRing(QQ, order="lex")
+ sage: n = 300 # chosen so that the computation takes > 1 second but not excessively long.
+ ....: # when Singular improves the algorithm or hardware gets faster, increase n.
+ sage: f = z^n-2
+ sage: g = z^2-z-x^2*y-x*y^3
+ sage: alarm(0.5); f.quo_rem(g)
+ Traceback (most recent call last):
+ ...
+ AlarmInterrupt
+ sage: alarm(0.5); f.quo_rem(g)
+ Traceback (most recent call last):
+ ...
+ AlarmInterrupt
+ sage: q, r = f.quo_rem(g)
+ sage: len(dict(q))
+ 307638
+ sage: len(dict(r))
+ 11409
"""
cdef poly *quo
cdef poly *rem
@@ -5041,17 +5243,17 @@ cdef class MPolynomial_libsingular(MPolynomial_libsingular_base):
py_rem = self - right*py_quo
return py_quo, py_rem
- if n_GetChar(r.cf) > 1<<29:
- raise NotImplementedError("Division of multivariate polynomials over prime fields with characteristic > 2^29 is not implemented.")
-
- cdef int count = singular_polynomial_length_bounded(self._poly, 15)
- if count >= 15: # note that _right._poly must be of shorter length than self._poly for us to care about this call
+ if r != currRing:
+ rChangeCurrRing(r) # singclap_pdivide
+ start_catch_error()
+ try:
sig_on()
- if r!=currRing: rChangeCurrRing(r) # singclap_pdivide
- quo = singclap_pdivide( self._poly, right._poly, r )
- rem = p_Add_q(p_Copy(self._poly, r), p_Neg(pp_Mult_qq(right._poly, quo, r), r), r)
- if count >= 15:
+ quo = singclap_pdivide(self._poly, right._poly, r)
sig_off()
+ finally:
+ if check_error():
+ raise NotImplementedError("Division of multivariate polynomials over prime fields with characteristic > 2^29 is not implemented.")
+ rem = p_Add_q(p_Copy(self._poly, r), p_Neg(pp_Mult_qq(right._poly, quo, r), r), r)
return new_MP(parent, quo), new_MP(parent, rem)
def _singular_init_(self, singular=None):
@@ -5424,6 +5626,7 @@ cdef class MPolynomial_libsingular(MPolynomial_libsingular_base):
_p = p_Add_q(_p, mon, _ring)
return new_MP(self._parent, _p)
+ @coerce_binop
def resultant(self, MPolynomial_libsingular other, variable=None):
"""
Compute the resultant of this polynomial and the first
@@ -5479,40 +5682,91 @@ cdef class MPolynomial_libsingular(MPolynomial_libsingular_base):
sage: g=y^2+x
sage: f.resultant(g,y)
x^2 + x
+
+ sage: R. = GF(2^32+15)[]
+ sage: (x-z).resultant(y-z,z)
+ Traceback (most recent call last):
+ ...
+ NotImplementedError: Resultants of multivariate polynomials over prime fields with characteristic > 2^29 is not implemented.
+ sage: R. = Zmod(2^29-3)[]
+ sage: (x-z).resultant(y-z,z)
+ x + 536870908*y
+ sage: R. = GF(2^29+11)[]
+ sage: (x-z).resultant(y-z,z)
+ Traceback (most recent call last):
+ ...
+ NotImplementedError: Resultants of multivariate polynomials over prime fields with characteristic > 2^29 is not implemented.
+ sage: R. = Zmod(2^29+10)[]
+ sage: (x-z).resultant(y-z,z)
+ Traceback (most recent call last):
+ ...
+ NotImplementedError: Resultants require base fields or integer base ring.
+ sage: R. = GF((2^29-3)^2)[]
+ sage: (x-z).resultant(y-z,z)
+ x - y
+ sage: R. = Zmod(7^2)[]
+ sage: (x-z).resultant(y-z,z)
+ Traceback (most recent call last):
+ ...
+ NotImplementedError: Resultants require base fields or integer base ring.
+
+ Sometimes simple-looking computations can take a long time::
+
+ sage: R. = QQ[]
+ sage: n = 22 # chosen so that the computation takes > 1 second but not excessively long.
+ ....: # when Singular improves the algorithm or hardware gets faster, increase n.
+ sage: f = x^n+y^(n-1)+z^(n-2)+y^3*z^2
+ sage: g = x^(n-3)+y^(n-4)+z^(n-5)+y*z
+ sage: h = f.resultant(g, x)
+ sage: len(dict(h))
+ 89
+
+ As such we test the computation is interruptible (previously it wasn't)::
+
+ sage: alarm(0.5); h = f.resultant(g, x)
+ Traceback (most recent call last):
+ ...
+ AlarmInterrupt
+
+ Test again to ensure interrupt does not make the internal state inconsistent::
+
+ sage: alarm(0.5); h = f.resultant(g, x); cancel_alarm()
+ Traceback (most recent call last):
+ ...
+ AlarmInterrupt
+ sage: h = f.resultant(g, x)
+ sage: len(dict(h))
+ 89
"""
cdef ring *_ring = self._parent_ring
cdef poly *rt
if variable is None:
variable = self.parent().gen(0)
-
- if self._parent is not other._parent:
- raise TypeError("first parameter needs to be an element of self.parent()")
-
- if not variable.parent() is self.parent():
+ elif variable.parent() is not self.parent():
raise TypeError("second parameter needs to be an element of self.parent() or None")
- if n_GetChar(_ring.cf) > 1<<29:
- raise NotImplementedError("Resultants of multivariate polynomials over prime fields with characteristic > 2^29 is not implemented.")
-
if isinstance(self._parent._base, IntegerRing_class):
ret = self.change_ring(QQ).resultant(other.change_ring(QQ),
variable.change_ring(QQ))
return ret.change_ring(ZZ)
- elif not self._parent._base.is_field():
- raise ValueError("Resultants require base fields or integer base ring.")
- cdef int count = singular_polynomial_length_bounded(self._poly, 20) \
- + singular_polynomial_length_bounded(other._poly,20)
- if count >= 20:
+ start_catch_error()
+ try:
sig_on()
- if _ring != currRing: rChangeCurrRing(_ring) # singclap_resultant
- rt = singclap_resultant(p_Copy(self._poly, _ring),
- p_Copy(other._poly, _ring),
- p_Copy((variable)._poly, _ring ),
- _ring)
- if count >= 20:
+ if _ring != currRing:
+ rChangeCurrRing(_ring) # singclap_resultant
+ rt = singclap_resultant(p_Copy(self._poly, _ring),
+ p_Copy(other._poly, _ring),
+ p_Copy((variable)._poly, _ring),
+ _ring)
sig_off()
+ finally:
+ if check_error():
+ if isinstance(self._parent._base, FiniteField_prime_modn):
+ raise NotImplementedError("Resultants of multivariate polynomials over prime fields with characteristic > 2^29 is not implemented.")
+ raise NotImplementedError("Resultants require base fields or integer base ring.")
+
return new_MP(self._parent, rt)
def coefficients(self):
diff --git a/src/sage/rings/polynomial/multi_polynomial_ring.py b/src/sage/rings/polynomial/multi_polynomial_ring.py
index 43f1c0f6294..26c32fe036c 100644
--- a/src/sage/rings/polynomial/multi_polynomial_ring.py
+++ b/src/sage/rings/polynomial/multi_polynomial_ring.py
@@ -60,14 +60,12 @@
# https://www.gnu.org/licenses/
# ****************************************************************************
-from sage.rings.ring import IntegralDomain
import sage.rings.fraction_field_element as fraction_field_element
from sage.rings.polynomial.multi_polynomial_ring_base import MPolynomialRing_base, is_MPolynomialRing
from sage.rings.polynomial.polynomial_singular_interface import PolynomialRing_singular_repr
from sage.rings.polynomial.polydict import PolyDict, ETuple
from sage.rings.polynomial.term_order import TermOrder
-
import sage.interfaces.abc
try:
@@ -558,9 +556,9 @@ def __call__(self, x=0, check=True):
c = self.base_ring()(x)
return MPolynomial_polydict(self, {self._zero_tuple: c})
-# The following methods are handy for implementing Groebner
-# basis algorithms. They do only superficial type/sanity checks
-# and should be called carefully.
+ # The following methods are handy for implementing Groebner
+ # basis algorithms. They do only superficial type/sanity checks
+ # and should be called carefully.
def monomial_quotient(self, f, g, coeff=False):
r"""
@@ -930,21 +928,17 @@ def sum(self, terms):
elt = PolyDict({}, check=False)
for t in terms:
elt += self(t).element()
- # NOTE: here we should be using self.element_class but polynomial rings are not complient
- # with categories...
+ # NOTE: here we should be using self.element_class but
+ # polynomial rings are not complient with categories...
from sage.rings.polynomial.multi_polynomial_element import MPolynomial_polydict
return MPolynomial_polydict(self, elt)
-class MPolynomialRing_polydict_domain(IntegralDomain,
- MPolynomialRing_polydict):
+class MPolynomialRing_polydict_domain(MPolynomialRing_polydict):
def __init__(self, base_ring, n, names, order):
order = TermOrder(order, n)
MPolynomialRing_polydict.__init__(self, base_ring, n, names, order)
- def is_integral_domain(self, proof=True):
- return True
-
def is_field(self, proof=True):
if self.ngens() == 0:
return self.base_ring().is_field(proof)
diff --git a/src/sage/rings/polynomial/multi_polynomial_ring_base.pyx b/src/sage/rings/polynomial/multi_polynomial_ring_base.pyx
index ac5e445908d..0434679d93d 100644
--- a/src/sage/rings/polynomial/multi_polynomial_ring_base.pyx
+++ b/src/sage/rings/polynomial/multi_polynomial_ring_base.pyx
@@ -142,7 +142,7 @@ cdef class MPolynomialRing_base(CommutativeRing):
Multivariate Polynomial Ring in x, y over Rational Field
"""
base = self.base_ring()
- if isinstance(base, MPolynomialRing_base) or isinstance(base, polynomial_ring.PolynomialRing_general):
+ if isinstance(base, (MPolynomialRing_base, polynomial_ring.PolynomialRing_generic)):
from sage.rings.polynomial.flatten import FlatteningMorphism
return FlatteningMorphism(self)
else:
@@ -602,7 +602,7 @@ cdef class MPolynomialRing_base(CommutativeRing):
elif self.base_ring().has_coerce_map_from(P._mpoly_base_ring(self.variable_names())):
return self(x)
- elif isinstance(P, polynomial_ring.PolynomialRing_general):
+ elif isinstance(P, polynomial_ring.PolynomialRing_generic):
if P.variable_name() in self.variable_names():
if self.has_coerce_map_from(P.base_ring()):
return self(x)
diff --git a/src/sage/rings/polynomial/pbori/pbori.pyx b/src/sage/rings/polynomial/pbori/pbori.pyx
index 686edf8892d..14a929c3238 100644
--- a/src/sage/rings/polynomial/pbori/pbori.pyx
+++ b/src/sage/rings/polynomial/pbori/pbori.pyx
@@ -194,7 +194,7 @@ from sage.rings.finite_rings.finite_field_constructor import FiniteField as GF
from sage.rings.polynomial.polynomial_element cimport Polynomial
from sage.rings.polynomial.multi_polynomial_ideal import MPolynomialIdeal
from sage.rings.polynomial.term_order import TermOrder
-from sage.rings.polynomial.polynomial_ring import PolynomialRing_general
+from sage.rings.polynomial.polynomial_ring import PolynomialRing_generic
from sage.rings.ideal import FieldIdeal
@@ -674,7 +674,7 @@ cdef class BooleanPolynomialRing(BooleanPolynomialRing_base):
"""
if self._base.has_coerce_map_from(S):
return True
- if isinstance(S, (MPolynomialRing_base, PolynomialRing_general,
+ if isinstance(S, (MPolynomialRing_base, PolynomialRing_generic,
BooleanMonomialMonoid)):
try:
get_var_mapping(self, S)
diff --git a/src/sage/rings/polynomial/polynomial_element.pyx b/src/sage/rings/polynomial/polynomial_element.pyx
index 389e538f83e..05de5dfe104 100644
--- a/src/sage/rings/polynomial/polynomial_element.pyx
+++ b/src/sage/rings/polynomial/polynomial_element.pyx
@@ -118,7 +118,7 @@ from sage.arith.functions import lcm
from sage.rings.polynomial import polynomial_fateman
from sage.rings.ideal import Ideal_generic
-from sage.rings.polynomial.polynomial_ring import PolynomialRing_general
+from sage.rings.polynomial.polynomial_ring import PolynomialRing_generic
from sage.rings.polynomial.multi_polynomial_ring import MPolynomialRing_base
from sage.rings.polynomial.multi_polynomial cimport MPolynomial
from sage.rings.polynomial.polynomial_quotient_ring_element import PolynomialQuotientRingElement
@@ -7522,7 +7522,7 @@ cdef class Polynomial(CommutativePolynomial):
raise TypeError("p2 must be a polynomial")
p1, p2 = coercion_model.canonical_coercion(p1, p2)
K = p1.parent()
- assert isinstance(p1.parent(), PolynomialRing_general)
+ assert isinstance(p1.parent(), PolynomialRing_generic)
S = K.base_ring()
Sf = S.fraction_field()
diff --git a/src/sage/rings/polynomial/polynomial_ring.py b/src/sage/rings/polynomial/polynomial_ring.py
index 8391d791e92..6be288de70f 100644
--- a/src/sage/rings/polynomial/polynomial_ring.py
+++ b/src/sage/rings/polynomial/polynomial_ring.py
@@ -141,6 +141,7 @@
import sys
+from sage.misc.superseded import deprecation
from sage.structure.element import Element
from sage.structure.category_object import check_default_category
@@ -149,7 +150,7 @@
from sage.categories.principal_ideal_domains import PrincipalIdealDomains
from sage.categories.rings import Rings
-from sage.rings.ring import (Ring, IntegralDomain)
+from sage.rings.ring import Ring, CommutativeRing
from sage.structure.element import RingElement
import sage.rings.rational_field as rational_field
from sage.rings.rational_field import QQ
@@ -193,7 +194,7 @@ def is_PolynomialRing(x):
sage: is_PolynomialRing(2)
doctest:warning...
DeprecationWarning: The function is_PolynomialRing is deprecated;
- use 'isinstance(..., PolynomialRing_general)' instead.
+ use 'isinstance(..., PolynomialRing_generic)' instead.
See https://github.com/sagemath/sage/issues/38266 for details.
False
@@ -232,13 +233,13 @@ def is_PolynomialRing(x):
from sage.misc.superseded import deprecation
deprecation(38266,
"The function is_PolynomialRing is deprecated; "
- "use 'isinstance(..., PolynomialRing_general)' instead.")
- return isinstance(x, PolynomialRing_general)
+ "use 'isinstance(..., PolynomialRing_generic)' instead.")
+ return isinstance(x, PolynomialRing_generic)
#########################################################################################
-class PolynomialRing_general(Ring):
+class PolynomialRing_generic(Ring):
"""
Univariate polynomial ring over a ring.
"""
@@ -534,12 +535,12 @@ def _implementation_names(cls, implementation, base_ring, sparse=False):
EXAMPLES::
- sage: from sage.rings.polynomial.polynomial_ring import PolynomialRing_general
- sage: PolynomialRing_general._implementation_names(None, ZZ, True)
+ sage: from sage.rings.polynomial.polynomial_ring import PolynomialRing_generic
+ sage: PolynomialRing_generic._implementation_names(None, ZZ, True)
[None, 'generic']
- sage: PolynomialRing_general._implementation_names("generic", ZZ, True)
+ sage: PolynomialRing_generic._implementation_names("generic", ZZ, True)
[None, 'generic']
- sage: PolynomialRing_general._implementation_names("xyzzy", ZZ, True)
+ sage: PolynomialRing_generic._implementation_names("xyzzy", ZZ, True)
Traceback (most recent call last):
...
ValueError: unknown implementation 'xyzzy' for sparse polynomial rings over Integer Ring
@@ -563,8 +564,8 @@ def _implementation_names_impl(implementation, base_ring, sparse):
EXAMPLES::
- sage: from sage.rings.polynomial.polynomial_ring import PolynomialRing_general
- sage: PolynomialRing_general._implementation_names_impl("xyzzy", ZZ, True)
+ sage: from sage.rings.polynomial.polynomial_ring import PolynomialRing_generic
+ sage: PolynomialRing_generic._implementation_names_impl("xyzzy", ZZ, True)
NotImplemented
"""
if implementation is None or implementation == "generic":
@@ -642,7 +643,7 @@ def flattening_morphism(self):
"""
from .multi_polynomial_ring import MPolynomialRing_base
base = self.base_ring()
- if isinstance(base, (PolynomialRing_general, MPolynomialRing_base)):
+ if isinstance(base, (PolynomialRing_generic, MPolynomialRing_base)):
from .flatten import FlatteningMorphism
return FlatteningMorphism(self)
else:
@@ -827,7 +828,7 @@ def _coerce_map_from_(self, P):
# polynomial rings in the same variable over a base that canonically
# coerces into self.base_ring()
- if isinstance(P, PolynomialRing_general):
+ if isinstance(P, PolynomialRing_generic):
if self.construction()[0] != P.construction()[0]:
# Construction (including variable names) must be the
# same to allow coercion
@@ -1590,7 +1591,7 @@ def _polys_degree(self, of_degree):
coeffs.reverse()
yield self(coeffs)
- def _polys_max( self, max_degree ):
+ def _polys_max(self, max_degree):
"""
Refer to polynomials() for full documentation.
"""
@@ -1617,7 +1618,7 @@ def _Karatsuba_threshold(self):
0
"""
base_ring = self.base_ring()
- if isinstance(base_ring, PolynomialRing_general):
+ if isinstance(base_ring, PolynomialRing_generic):
return 0
try:
from sage.matrix.matrix_space import MatrixSpace
@@ -1669,7 +1670,7 @@ def set_karatsuba_threshold(self, Karatsuba_threshold):
"""
self._Karatsuba_threshold = int(Karatsuba_threshold)
- def polynomials( self, of_degree=None, max_degree=None ):
+ def polynomials(self, of_degree=None, max_degree=None):
"""
Return an iterator over the polynomials of specified degree.
@@ -1733,7 +1734,7 @@ def polynomials( self, of_degree=None, max_degree=None ):
return self._polys_max( max_degree )
raise ValueError("you should pass exactly one of of_degree and max_degree")
- def monics( self, of_degree=None, max_degree=None ):
+ def monics(self, of_degree=None, max_degree=None):
"""
Return an iterator over the monic polynomials of specified degree.
@@ -1794,7 +1795,11 @@ def monics( self, of_degree=None, max_degree=None ):
raise ValueError("you should pass exactly one of of_degree and max_degree")
-class PolynomialRing_commutative(PolynomialRing_general):
+# PolynomialRing_general is deprecated since 2024-12-03. See Issue #38207.
+PolynomialRing_general = PolynomialRing_generic
+
+
+class PolynomialRing_commutative(PolynomialRing_generic):
"""
Univariate polynomial ring over a commutative ring.
"""
@@ -1808,7 +1813,7 @@ def __init__(self, base_ring, name=None, sparse=False, implementation=None,
else:
defaultcat = polynomial_default_category(base_ring.category(), 1)
category = check_default_category(defaultcat, category)
- PolynomialRing_general.__init__(self, base_ring, name=name,
+ PolynomialRing_generic.__init__(self, base_ring, name=name,
sparse=sparse, implementation=implementation,
element_class=element_class, category=category)
@@ -1923,8 +1928,7 @@ def _roots_univariate_polynomial(self, p, ring=None, multiplicities=True, algori
return roots
-class PolynomialRing_integral_domain(PolynomialRing_commutative, PolynomialRing_singular_repr,
- IntegralDomain):
+class PolynomialRing_integral_domain(PolynomialRing_commutative, PolynomialRing_singular_repr, CommutativeRing):
def __init__(self, base_ring, name='x', sparse=False, implementation=None,
element_class=None, category=None):
"""
diff --git a/src/sage/rings/polynomial/polynomial_ring_constructor.py b/src/sage/rings/polynomial/polynomial_ring_constructor.py
index 5cbc74dd1d5..78074c8a1d2 100644
--- a/src/sage/rings/polynomial/polynomial_ring_constructor.py
+++ b/src/sage/rings/polynomial/polynomial_ring_constructor.py
@@ -798,7 +798,7 @@ def _single_variate(base_ring, name, sparse=None, implementation=None, order=Non
from sage.rings.semirings.tropical_polynomial import TropicalPolynomialSemiring
constructor = TropicalPolynomialSemiring
elif base_ring not in _CommutativeRings:
- constructor = polynomial_ring.PolynomialRing_general
+ constructor = polynomial_ring.PolynomialRing_generic
elif base_ring in _CompleteDiscreteValuationRings:
constructor = polynomial_ring.PolynomialRing_cdvr
elif base_ring in _CompleteDiscreteValuationFields:
diff --git a/src/sage/rings/polynomial/weil/meson.build b/src/sage/rings/polynomial/weil/meson.build
index 2c9bd006919..77432ffef30 100644
--- a/src/sage/rings/polynomial/weil/meson.build
+++ b/src/sage/rings/polynomial/weil/meson.build
@@ -1,4 +1,5 @@
py.install_sources(
+ '__init__.py',
'all.py',
'power_sums.h',
subdir: 'sage/rings/polynomial/weil',
diff --git a/src/sage/rings/polynomial/weil/weil_polynomials.pyx b/src/sage/rings/polynomial/weil/weil_polynomials.pyx
old mode 100755
new mode 100644
diff --git a/src/sage/rings/power_series_pari.pyx b/src/sage/rings/power_series_pari.pyx
index baeef616e02..350362cadb7 100644
--- a/src/sage/rings/power_series_pari.pyx
+++ b/src/sage/rings/power_series_pari.pyx
@@ -416,7 +416,7 @@ cdef class PowerSeries_pari(PowerSeries):
# to an ideal I, and the element a lies in I. Here we only
# implement a few special cases.
from sage.rings.padics.padic_generic import pAdicGeneric
- from sage.rings.polynomial.polynomial_ring import PolynomialRing_general
+ from sage.rings.polynomial.polynomial_ring import PolynomialRing_generic
from sage.rings.power_series_ring import PowerSeriesRing_generic
from sage.rings.laurent_series_ring import LaurentSeriesRing
if isinstance(Q, pAdicGeneric):
@@ -433,7 +433,7 @@ cdef class PowerSeries_pari(PowerSeries):
# subst(1 + O(x), x, 1/y) yields O(y^-1).
if a.valuation() <= 0:
raise ValueError("can only substitute elements of positive valuation")
- elif isinstance(Q, PolynomialRing_general):
+ elif isinstance(Q, PolynomialRing_generic):
Q = Q.completion(Q.gen())
elif Q.is_exact() and not a:
pass
diff --git a/src/sage/rings/power_series_ring.py b/src/sage/rings/power_series_ring.py
index 512ab8d6e20..42ca735e671 100644
--- a/src/sage/rings/power_series_ring.py
+++ b/src/sage/rings/power_series_ring.py
@@ -148,7 +148,7 @@
from sage.rings.fraction_field_element import FractionFieldElement
from sage.rings.infinity import infinity
from sage.rings.polynomial.multi_polynomial_ring_base import MPolynomialRing_base
-from sage.rings.polynomial.polynomial_ring import PolynomialRing_general
+from sage.rings.polynomial.polynomial_ring import PolynomialRing_generic
from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing
from sage.structure.category_object import normalize_names
from sage.structure.element import Expression, parent
@@ -717,7 +717,7 @@ def _coerce_map_from_(self, S):
"""
if self.base_ring().has_coerce_map_from(S):
return True
- if (isinstance(S, (PolynomialRing_general, PowerSeriesRing_generic, LazyPowerSeriesRing))
+ if (isinstance(S, (PolynomialRing_generic, PowerSeriesRing_generic, LazyPowerSeriesRing))
and self.base_ring().has_coerce_map_from(S.base_ring())
and self.variable_names() == S.variable_names()):
return True
diff --git a/src/sage/rings/quotient_ring.py b/src/sage/rings/quotient_ring.py
index c867ba41bbc..7e3dd8c6d53 100644
--- a/src/sage/rings/quotient_ring.py
+++ b/src/sage/rings/quotient_ring.py
@@ -502,7 +502,7 @@ def __init__(self, R, I, names, category=None):
# However, we don't just want to use the given category without mixing in
# some quotient stuff - unless Parent.__init__ was called
# previously, in which case the quotient ring stuff is just
- # a vaste of time. This is the case for FiniteField_prime_modn.
+ # a waste of time. This is the case for FiniteField_prime_modn.
if not self._is_category_initialized():
if category is None:
try:
diff --git a/src/sage/rings/ring_extension_morphism.pyx b/src/sage/rings/ring_extension_morphism.pyx
index d4aad7f8253..7294e90c319 100644
--- a/src/sage/rings/ring_extension_morphism.pyx
+++ b/src/sage/rings/ring_extension_morphism.pyx
@@ -461,7 +461,7 @@ cdef class RingExtensionHomomorphism(RingMap):
if self.base_map() is not None:
s += "with map on base ring"
ss = self.base_map()._repr_defn()
- ss = re.sub('\nwith map on base ring:?$', '', ss, 0, re.MULTILINE)
+ ss = re.sub('\nwith map on base ring:?$', '', ss, flags=re.MULTILINE)
if ss != "": s += ":\n" + ss
if s != "" and s[-1] == "\n":
s = s[:-1]
diff --git a/src/sage/rings/semirings/meson.build b/src/sage/rings/semirings/meson.build
index e1e4e627ba3..6cbfce4f84c 100644
--- a/src/sage/rings/semirings/meson.build
+++ b/src/sage/rings/semirings/meson.build
@@ -1,4 +1,5 @@
py.install_sources(
+ '__init__.py',
'all.py',
'non_negative_integer_semiring.py',
'tropical_mpolynomial.py',
diff --git a/src/sage/rings/semirings/tropical_polynomial.py b/src/sage/rings/semirings/tropical_polynomial.py
index 4e4e239edd2..42caa0601f9 100644
--- a/src/sage/rings/semirings/tropical_polynomial.py
+++ b/src/sage/rings/semirings/tropical_polynomial.py
@@ -806,7 +806,7 @@ def random_element(self, degree=(-1, 2), monic=False, *args, **kwds):
.. SEEALSO::
- :meth:`sage.rings.polynomial.polynomial_ring.PolynomialRing_general.random_element`
+ :meth:`sage.rings.polynomial.polynomial_ring.PolynomialRing_generic.random_element`
EXAMPLES:
diff --git a/src/sage/rings/valuation/augmented_valuation.py b/src/sage/rings/valuation/augmented_valuation.py
index b9f0229f787..5b4666d45cb 100644
--- a/src/sage/rings/valuation/augmented_valuation.py
+++ b/src/sage/rings/valuation/augmented_valuation.py
@@ -538,8 +538,8 @@ def extensions(self, ring):
if ring is self.domain():
return [self]
- from sage.rings.polynomial.polynomial_ring import PolynomialRing_general
- if isinstance(ring, PolynomialRing_general): # univariate
+ from sage.rings.polynomial.polynomial_ring import PolynomialRing_generic
+ if isinstance(ring, PolynomialRing_generic): # univariate
base_valuations = self._base_valuation.extensions(ring)
phi = self.phi().change_ring(ring.base_ring())
@@ -578,8 +578,8 @@ def restriction(self, ring):
base = self._base_valuation.restriction(ring)
if ring.is_subring(self.domain().base_ring()):
return base
- from sage.rings.polynomial.polynomial_ring import PolynomialRing_general
- if isinstance(ring, PolynomialRing_general): # univariate
+ from sage.rings.polynomial.polynomial_ring import PolynomialRing_generic
+ if isinstance(ring, PolynomialRing_generic): # univariate
return base.augmentation(self.phi().change_ring(ring.base_ring()), self._mu)
return super().restriction(ring)
@@ -790,8 +790,8 @@ def change_domain(self, ring):
sage: v.change_domain(QQ['x'])
[ Gauss valuation induced by 2-adic valuation, v(x) = 1 ]
"""
- from sage.rings.polynomial.polynomial_ring import PolynomialRing_general
- if isinstance(ring, PolynomialRing_general) and ring.variable_name() == self.domain().variable_name():
+ from sage.rings.polynomial.polynomial_ring import PolynomialRing_generic
+ if isinstance(ring, PolynomialRing_generic) and ring.variable_name() == self.domain().variable_name():
return self._base_valuation.change_domain(ring).augmentation(self.phi().change_ring(ring.base_ring()), self._mu, check=False)
return super().change_domain(ring)
diff --git a/src/sage/rings/valuation/developing_valuation.py b/src/sage/rings/valuation/developing_valuation.py
index 8b77224f591..a73130c9cea 100644
--- a/src/sage/rings/valuation/developing_valuation.py
+++ b/src/sage/rings/valuation/developing_valuation.py
@@ -81,8 +81,8 @@ def __init__(self, parent, phi):
DiscretePseudoValuation.__init__(self, parent)
domain = parent.domain()
- from sage.rings.polynomial.polynomial_ring import PolynomialRing_general
- if not isinstance(domain, PolynomialRing_general) or not domain.ngens() == 1:
+ from sage.rings.polynomial.polynomial_ring import PolynomialRing_generic
+ if not isinstance(domain, PolynomialRing_generic) or not domain.ngens() == 1:
raise TypeError("domain must be a univariate polynomial ring but %r is not" % (domain,))
phi = domain.coerce(phi)
diff --git a/src/sage/rings/valuation/gauss_valuation.py b/src/sage/rings/valuation/gauss_valuation.py
index 0e867e0a2f5..4fc1c555a79 100644
--- a/src/sage/rings/valuation/gauss_valuation.py
+++ b/src/sage/rings/valuation/gauss_valuation.py
@@ -88,8 +88,8 @@ def create_key(self, domain, v=None):
...
ValueError: the domain of v must be the base ring of domain but 2-adic valuation is not defined over Integer Ring but over Rational Field
"""
- from sage.rings.polynomial.polynomial_ring import PolynomialRing_general
- if not isinstance(domain, PolynomialRing_general):
+ from sage.rings.polynomial.polynomial_ring import PolynomialRing_generic
+ if not isinstance(domain, PolynomialRing_generic):
raise TypeError("GaussValuations can only be created over polynomial rings but %r is not a polynomial ring" % (domain,))
if not domain.ngens() == 1:
raise NotImplementedError("domain must be univariate but %r is not univariate" % (domain,))
@@ -509,8 +509,8 @@ def change_domain(self, ring):
sage: w.change_domain(QQ['x'])
Gauss valuation induced by 2-adic valuation
"""
- from sage.rings.polynomial.polynomial_ring import PolynomialRing_general
- if isinstance(ring, PolynomialRing_general) and ring.ngens() == 1:
+ from sage.rings.polynomial.polynomial_ring import PolynomialRing_generic
+ if isinstance(ring, PolynomialRing_generic) and ring.ngens() == 1:
base_valuation = self._base_valuation.change_domain(ring.base_ring())
return GaussValuation(self.domain().change_ring(ring.base_ring()), base_valuation)
return super().change_domain(ring)
@@ -527,8 +527,8 @@ def extensions(self, ring):
sage: w.extensions(GaussianIntegers()['x']) # needs sage.rings.number_field
[Gauss valuation induced by 2-adic valuation]
"""
- from sage.rings.polynomial.polynomial_ring import PolynomialRing_general
- if isinstance(ring, PolynomialRing_general) and ring.ngens() == 1:
+ from sage.rings.polynomial.polynomial_ring import PolynomialRing_generic
+ if isinstance(ring, PolynomialRing_generic) and ring.ngens() == 1:
if self.domain().is_subring(ring):
return [GaussValuation(ring, w) for w in self._base_valuation.extensions(ring.base_ring())]
return super().extensions(ring)
@@ -547,8 +547,8 @@ def restriction(self, ring):
"""
if ring.is_subring(self.domain().base_ring()):
return self._base_valuation.restriction(ring)
- from sage.rings.polynomial.polynomial_ring import PolynomialRing_general
- if isinstance(ring, PolynomialRing_general) and ring.ngens() == 1:
+ from sage.rings.polynomial.polynomial_ring import PolynomialRing_generic
+ if isinstance(ring, PolynomialRing_generic) and ring.ngens() == 1:
if ring.base().is_subring(self.domain().base()):
return GaussValuation(ring, self._base_valuation.restriction(ring.base()))
return super().restriction(ring)
diff --git a/src/sage/rings/valuation/limit_valuation.py b/src/sage/rings/valuation/limit_valuation.py
index 86a64d23f99..19e5c71e95c 100644
--- a/src/sage/rings/valuation/limit_valuation.py
+++ b/src/sage/rings/valuation/limit_valuation.py
@@ -409,8 +409,8 @@ def extensions(self, ring):
"""
if self.domain() is ring:
return [self]
- from sage.rings.polynomial.polynomial_ring import PolynomialRing_general
- if isinstance(ring, PolynomialRing_general) and self.domain().base_ring().is_subring(ring.base_ring()):
+ from sage.rings.polynomial.polynomial_ring import PolynomialRing_generic
+ if isinstance(ring, PolynomialRing_generic) and self.domain().base_ring().is_subring(ring.base_ring()):
if self.domain().base_ring().fraction_field() is ring.base_ring():
return [LimitValuation(self._initial_approximation.change_domain(ring),
self._G.change_ring(ring.base_ring()))]
@@ -661,8 +661,8 @@ def residue_ring(self):
# the approximation ends in v(phi)=infty
return R
else:
- from sage.rings.polynomial.polynomial_ring import PolynomialRing_general
- assert (isinstance(R, PolynomialRing_general))
+ from sage.rings.polynomial.polynomial_ring import PolynomialRing_generic
+ assert (isinstance(R, PolynomialRing_generic))
return R.base_ring()
def _ge_(self, other):
diff --git a/src/sage/rings/valuation/valuation_space.py b/src/sage/rings/valuation/valuation_space.py
index d5f5dc8e5ec..7736f787600 100644
--- a/src/sage/rings/valuation/valuation_space.py
+++ b/src/sage/rings/valuation/valuation_space.py
@@ -515,8 +515,8 @@ def residue_field(self):
from sage.categories.fields import Fields
if ret in Fields():
return ret
- from sage.rings.polynomial.polynomial_ring import PolynomialRing_general
- if isinstance(ret, PolynomialRing_general):
+ from sage.rings.polynomial.polynomial_ring import PolynomialRing_generic
+ if isinstance(ret, PolynomialRing_generic):
from sage.rings.function_field.constructor import FunctionField
return FunctionField(ret.base_ring().fraction_field(), names=(ret.variable_name(),))
return ret.fraction_field()
diff --git a/src/sage/sat/meson.build b/src/sage/sat/meson.build
index a1a0246dfce..85d9be286e2 100644
--- a/src/sage/sat/meson.build
+++ b/src/sage/sat/meson.build
@@ -1,4 +1,9 @@
-py.install_sources('all.py', 'boolean_polynomials.py', subdir: 'sage/sat')
+py.install_sources(
+ '__init__.py',
+ 'all.py',
+ 'boolean_polynomials.py',
+ subdir: 'sage/sat',
+)
install_subdir('converters', install_dir: sage_install_dir / 'sat')
subdir('solvers')
diff --git a/src/sage/schemes/affine/affine_homset.py b/src/sage/schemes/affine/affine_homset.py
old mode 100755
new mode 100644
diff --git a/src/sage/schemes/affine/affine_morphism.py b/src/sage/schemes/affine/affine_morphism.py
old mode 100755
new mode 100644
diff --git a/src/sage/schemes/affine/affine_point.py b/src/sage/schemes/affine/affine_point.py
old mode 100755
new mode 100644
diff --git a/src/sage/schemes/affine/affine_rational_point.py b/src/sage/schemes/affine/affine_rational_point.py
old mode 100755
new mode 100644
diff --git a/src/sage/schemes/affine/affine_space.py b/src/sage/schemes/affine/affine_space.py
old mode 100755
new mode 100644
index 42aeae0e2f9..702381f6ea4
--- a/src/sage/schemes/affine/affine_space.py
+++ b/src/sage/schemes/affine/affine_space.py
@@ -15,7 +15,7 @@
from sage.rings.integer_ring import ZZ
from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing
from sage.rings.rational_field import RationalField
-from sage.rings.polynomial.polynomial_ring import PolynomialRing_general
+from sage.rings.polynomial.polynomial_ring import PolynomialRing_generic
from sage.rings.polynomial.multi_polynomial_ring import MPolynomialRing_base
from sage.rings.finite_rings.finite_field_base import FiniteField
from sage.categories.map import Map
@@ -109,7 +109,7 @@ def AffineSpace(n, R=None, names=None, ambient_projective_space=None,
...
NameError: variable names passed to AffineSpace conflict with names in ring
"""
- if isinstance(n, (MPolynomialRing_base, PolynomialRing_general)) and R is None:
+ if isinstance(n, (MPolynomialRing_base, PolynomialRing_generic)) and R is None:
R = n
if names is not None:
# Check for the case that the user provided a variable name
diff --git a/src/sage/schemes/affine/affine_subscheme.py b/src/sage/schemes/affine/affine_subscheme.py
old mode 100755
new mode 100644
diff --git a/src/sage/schemes/berkovich/berkovich_cp_element.py b/src/sage/schemes/berkovich/berkovich_cp_element.py
old mode 100755
new mode 100644
diff --git a/src/sage/schemes/berkovich/berkovich_space.py b/src/sage/schemes/berkovich/berkovich_space.py
old mode 100755
new mode 100644
diff --git a/src/sage/schemes/curves/affine_curve.py b/src/sage/schemes/curves/affine_curve.py
old mode 100755
new mode 100644
diff --git a/src/sage/schemes/curves/closed_point.py b/src/sage/schemes/curves/closed_point.py
old mode 100755
new mode 100644
diff --git a/src/sage/schemes/curves/constructor.py b/src/sage/schemes/curves/constructor.py
old mode 100755
new mode 100644
diff --git a/src/sage/schemes/curves/curve.py b/src/sage/schemes/curves/curve.py
old mode 100755
new mode 100644
diff --git a/src/sage/schemes/curves/plane_curve_arrangement.py b/src/sage/schemes/curves/plane_curve_arrangement.py
old mode 100755
new mode 100644
diff --git a/src/sage/schemes/curves/point.py b/src/sage/schemes/curves/point.py
old mode 100755
new mode 100644
diff --git a/src/sage/schemes/curves/projective_curve.py b/src/sage/schemes/curves/projective_curve.py
old mode 100755
new mode 100644
diff --git a/src/sage/schemes/curves/zariski_vankampen.py b/src/sage/schemes/curves/zariski_vankampen.py
old mode 100755
new mode 100644
diff --git a/src/sage/schemes/cyclic_covers/charpoly_frobenius.py b/src/sage/schemes/cyclic_covers/charpoly_frobenius.py
old mode 100755
new mode 100644
diff --git a/src/sage/schemes/cyclic_covers/constructor.py b/src/sage/schemes/cyclic_covers/constructor.py
old mode 100755
new mode 100644
diff --git a/src/sage/schemes/cyclic_covers/cycliccover_finite_field.py b/src/sage/schemes/cyclic_covers/cycliccover_finite_field.py
old mode 100755
new mode 100644
diff --git a/src/sage/schemes/cyclic_covers/cycliccover_generic.py b/src/sage/schemes/cyclic_covers/cycliccover_generic.py
old mode 100755
new mode 100644
diff --git a/src/sage/schemes/elliptic_curves/BSD.py b/src/sage/schemes/elliptic_curves/BSD.py
old mode 100755
new mode 100644
diff --git a/src/sage/schemes/elliptic_curves/Qcurves.py b/src/sage/schemes/elliptic_curves/Qcurves.py
old mode 100755
new mode 100644
diff --git a/src/sage/schemes/elliptic_curves/cm.py b/src/sage/schemes/elliptic_curves/cm.py
old mode 100755
new mode 100644
diff --git a/src/sage/schemes/elliptic_curves/constructor.py b/src/sage/schemes/elliptic_curves/constructor.py
old mode 100755
new mode 100644
diff --git a/src/sage/schemes/elliptic_curves/descent_two_isogeny.pyx b/src/sage/schemes/elliptic_curves/descent_two_isogeny.pyx
old mode 100755
new mode 100644
diff --git a/src/sage/schemes/elliptic_curves/ec_database.py b/src/sage/schemes/elliptic_curves/ec_database.py
old mode 100755
new mode 100644
diff --git a/src/sage/schemes/elliptic_curves/ell_curve_isogeny.py b/src/sage/schemes/elliptic_curves/ell_curve_isogeny.py
old mode 100755
new mode 100644
diff --git a/src/sage/schemes/elliptic_curves/ell_egros.py b/src/sage/schemes/elliptic_curves/ell_egros.py
old mode 100755
new mode 100644
diff --git a/src/sage/schemes/elliptic_curves/ell_field.py b/src/sage/schemes/elliptic_curves/ell_field.py
old mode 100755
new mode 100644
diff --git a/src/sage/schemes/elliptic_curves/ell_finite_field.py b/src/sage/schemes/elliptic_curves/ell_finite_field.py
old mode 100755
new mode 100644
diff --git a/src/sage/schemes/elliptic_curves/ell_generic.py b/src/sage/schemes/elliptic_curves/ell_generic.py
old mode 100755
new mode 100644
diff --git a/src/sage/schemes/elliptic_curves/ell_local_data.py b/src/sage/schemes/elliptic_curves/ell_local_data.py
old mode 100755
new mode 100644
diff --git a/src/sage/schemes/elliptic_curves/ell_modular_symbols.py b/src/sage/schemes/elliptic_curves/ell_modular_symbols.py
old mode 100755
new mode 100644
diff --git a/src/sage/schemes/elliptic_curves/ell_number_field.py b/src/sage/schemes/elliptic_curves/ell_number_field.py
old mode 100755
new mode 100644
diff --git a/src/sage/schemes/elliptic_curves/ell_padic_field.py b/src/sage/schemes/elliptic_curves/ell_padic_field.py
old mode 100755
new mode 100644
diff --git a/src/sage/schemes/elliptic_curves/ell_point.py b/src/sage/schemes/elliptic_curves/ell_point.py
old mode 100755
new mode 100644
diff --git a/src/sage/schemes/elliptic_curves/ell_rational_field.py b/src/sage/schemes/elliptic_curves/ell_rational_field.py
old mode 100755
new mode 100644
diff --git a/src/sage/schemes/elliptic_curves/ell_tate_curve.py b/src/sage/schemes/elliptic_curves/ell_tate_curve.py
old mode 100755
new mode 100644
diff --git a/src/sage/schemes/elliptic_curves/ell_torsion.py b/src/sage/schemes/elliptic_curves/ell_torsion.py
old mode 100755
new mode 100644
diff --git a/src/sage/schemes/elliptic_curves/ell_wp.py b/src/sage/schemes/elliptic_curves/ell_wp.py
old mode 100755
new mode 100644
diff --git a/src/sage/schemes/elliptic_curves/formal_group.py b/src/sage/schemes/elliptic_curves/formal_group.py
old mode 100755
new mode 100644
diff --git a/src/sage/schemes/elliptic_curves/gal_reps.py b/src/sage/schemes/elliptic_curves/gal_reps.py
old mode 100755
new mode 100644
diff --git a/src/sage/schemes/elliptic_curves/gal_reps_number_field.py b/src/sage/schemes/elliptic_curves/gal_reps_number_field.py
old mode 100755
new mode 100644
diff --git a/src/sage/schemes/elliptic_curves/heegner.py b/src/sage/schemes/elliptic_curves/heegner.py
old mode 100755
new mode 100644
diff --git a/src/sage/schemes/elliptic_curves/height.py b/src/sage/schemes/elliptic_curves/height.py
old mode 100755
new mode 100644
diff --git a/src/sage/schemes/elliptic_curves/hom.py b/src/sage/schemes/elliptic_curves/hom.py
old mode 100755
new mode 100644
diff --git a/src/sage/schemes/elliptic_curves/hom_composite.py b/src/sage/schemes/elliptic_curves/hom_composite.py
old mode 100755
new mode 100644
diff --git a/src/sage/schemes/elliptic_curves/hom_sum.py b/src/sage/schemes/elliptic_curves/hom_sum.py
old mode 100755
new mode 100644
diff --git a/src/sage/schemes/elliptic_curves/hom_velusqrt.py b/src/sage/schemes/elliptic_curves/hom_velusqrt.py
old mode 100755
new mode 100644
diff --git a/src/sage/schemes/elliptic_curves/isogeny_class.py b/src/sage/schemes/elliptic_curves/isogeny_class.py
old mode 100755
new mode 100644
diff --git a/src/sage/schemes/elliptic_curves/isogeny_small_degree.py b/src/sage/schemes/elliptic_curves/isogeny_small_degree.py
old mode 100755
new mode 100644
diff --git a/src/sage/schemes/elliptic_curves/jacobian.py b/src/sage/schemes/elliptic_curves/jacobian.py
old mode 100755
new mode 100644
diff --git a/src/sage/schemes/elliptic_curves/kodaira_symbol.py b/src/sage/schemes/elliptic_curves/kodaira_symbol.py
old mode 100755
new mode 100644
diff --git a/src/sage/schemes/elliptic_curves/kraus.py b/src/sage/schemes/elliptic_curves/kraus.py
old mode 100755
new mode 100644
diff --git a/src/sage/schemes/elliptic_curves/lseries_ell.py b/src/sage/schemes/elliptic_curves/lseries_ell.py
old mode 100755
new mode 100644
diff --git a/src/sage/schemes/elliptic_curves/meson.build b/src/sage/schemes/elliptic_curves/meson.build
index 3448c5d1c0a..b2a3dda08c9 100644
--- a/src/sage/schemes/elliptic_curves/meson.build
+++ b/src/sage/schemes/elliptic_curves/meson.build
@@ -1,6 +1,8 @@
py.install_sources(
'BSD.py',
'Qcurves.py',
+ '__init__.py',
+ 'addition_formulas_ring.py',
'all.py',
'cardinality.py',
'cm.py',
diff --git a/src/sage/schemes/elliptic_curves/mod_poly.py b/src/sage/schemes/elliptic_curves/mod_poly.py
old mode 100755
new mode 100644
diff --git a/src/sage/schemes/elliptic_curves/mod_sym_num.pyx b/src/sage/schemes/elliptic_curves/mod_sym_num.pyx
old mode 100755
new mode 100644
diff --git a/src/sage/schemes/elliptic_curves/modular_parametrization.py b/src/sage/schemes/elliptic_curves/modular_parametrization.py
old mode 100755
new mode 100644
diff --git a/src/sage/schemes/elliptic_curves/padic_lseries.py b/src/sage/schemes/elliptic_curves/padic_lseries.py
old mode 100755
new mode 100644
diff --git a/src/sage/schemes/elliptic_curves/padics.py b/src/sage/schemes/elliptic_curves/padics.py
old mode 100755
new mode 100644
diff --git a/src/sage/schemes/elliptic_curves/period_lattice.py b/src/sage/schemes/elliptic_curves/period_lattice.py
old mode 100755
new mode 100644
diff --git a/src/sage/schemes/elliptic_curves/period_lattice_region.pyx b/src/sage/schemes/elliptic_curves/period_lattice_region.pyx
old mode 100755
new mode 100644
diff --git a/src/sage/schemes/elliptic_curves/saturation.py b/src/sage/schemes/elliptic_curves/saturation.py
old mode 100755
new mode 100644
diff --git a/src/sage/schemes/elliptic_curves/sha_tate.py b/src/sage/schemes/elliptic_curves/sha_tate.py
old mode 100755
new mode 100644
diff --git a/src/sage/schemes/elliptic_curves/weierstrass_morphism.py b/src/sage/schemes/elliptic_curves/weierstrass_morphism.py
old mode 100755
new mode 100644
diff --git a/src/sage/schemes/elliptic_curves/weierstrass_transform.py b/src/sage/schemes/elliptic_curves/weierstrass_transform.py
old mode 100755
new mode 100644
diff --git a/src/sage/schemes/generic/algebraic_scheme.py b/src/sage/schemes/generic/algebraic_scheme.py
old mode 100755
new mode 100644
diff --git a/src/sage/schemes/generic/ambient_space.py b/src/sage/schemes/generic/ambient_space.py
old mode 100755
new mode 100644
diff --git a/src/sage/schemes/generic/divisor.py b/src/sage/schemes/generic/divisor.py
old mode 100755
new mode 100644
diff --git a/src/sage/schemes/generic/divisor_group.py b/src/sage/schemes/generic/divisor_group.py
old mode 100755
new mode 100644
diff --git a/src/sage/schemes/generic/glue.py b/src/sage/schemes/generic/glue.py
old mode 100755
new mode 100644
diff --git a/src/sage/schemes/generic/homset.py b/src/sage/schemes/generic/homset.py
old mode 100755
new mode 100644
diff --git a/src/sage/schemes/generic/hypersurface.py b/src/sage/schemes/generic/hypersurface.py
old mode 100755
new mode 100644
diff --git a/src/sage/schemes/generic/morphism.py b/src/sage/schemes/generic/morphism.py
old mode 100755
new mode 100644
diff --git a/src/sage/schemes/generic/point.py b/src/sage/schemes/generic/point.py
old mode 100755
new mode 100644
diff --git a/src/sage/schemes/generic/scheme.py b/src/sage/schemes/generic/scheme.py
old mode 100755
new mode 100644
diff --git a/src/sage/schemes/generic/spec.py b/src/sage/schemes/generic/spec.py
old mode 100755
new mode 100644
diff --git a/src/sage/schemes/hyperelliptic_curves/constructor.py b/src/sage/schemes/hyperelliptic_curves/constructor.py
old mode 100755
new mode 100644
diff --git a/src/sage/schemes/hyperelliptic_curves/hypellfrob.pyx b/src/sage/schemes/hyperelliptic_curves/hypellfrob.pyx
old mode 100755
new mode 100644
diff --git a/src/sage/schemes/hyperelliptic_curves/hyperelliptic_finite_field.py b/src/sage/schemes/hyperelliptic_curves/hyperelliptic_finite_field.py
old mode 100755
new mode 100644
diff --git a/src/sage/schemes/hyperelliptic_curves/hyperelliptic_generic.py b/src/sage/schemes/hyperelliptic_curves/hyperelliptic_generic.py
old mode 100755
new mode 100644
diff --git a/src/sage/schemes/hyperelliptic_curves/hyperelliptic_padic_field.py b/src/sage/schemes/hyperelliptic_curves/hyperelliptic_padic_field.py
old mode 100755
new mode 100644
diff --git a/src/sage/schemes/hyperelliptic_curves/hyperelliptic_rational_field.py b/src/sage/schemes/hyperelliptic_curves/hyperelliptic_rational_field.py
old mode 100755
new mode 100644
diff --git a/src/sage/schemes/hyperelliptic_curves/invariants.py b/src/sage/schemes/hyperelliptic_curves/invariants.py
old mode 100755
new mode 100644
diff --git a/src/sage/schemes/hyperelliptic_curves/jacobian_endomorphism_utils.py b/src/sage/schemes/hyperelliptic_curves/jacobian_endomorphism_utils.py
old mode 100755
new mode 100644
diff --git a/src/sage/schemes/hyperelliptic_curves/jacobian_generic.py b/src/sage/schemes/hyperelliptic_curves/jacobian_generic.py
old mode 100755
new mode 100644
diff --git a/src/sage/schemes/hyperelliptic_curves/jacobian_morphism.py b/src/sage/schemes/hyperelliptic_curves/jacobian_morphism.py
old mode 100755
new mode 100644
diff --git a/src/sage/schemes/hyperelliptic_curves/meson.build b/src/sage/schemes/hyperelliptic_curves/meson.build
index e4b017d4192..170d08baaca 100644
--- a/src/sage/schemes/hyperelliptic_curves/meson.build
+++ b/src/sage/schemes/hyperelliptic_curves/meson.build
@@ -1,5 +1,6 @@
inc_hypellfrob = include_directories('hypellfrob')
py.install_sources(
+ '__init__.py',
'all.py',
'constructor.py',
'hyperelliptic_finite_field.py',
diff --git a/src/sage/schemes/hyperelliptic_curves/mestre.py b/src/sage/schemes/hyperelliptic_curves/mestre.py
old mode 100755
new mode 100644
diff --git a/src/sage/schemes/hyperelliptic_curves/monsky_washnitzer.py b/src/sage/schemes/hyperelliptic_curves/monsky_washnitzer.py
old mode 100755
new mode 100644
diff --git a/src/sage/schemes/jacobians/abstract_jacobian.py b/src/sage/schemes/jacobians/abstract_jacobian.py
old mode 100755
new mode 100644
diff --git a/src/sage/schemes/meson.build b/src/sage/schemes/meson.build
index c74c532b930..4dac80900e9 100644
--- a/src/sage/schemes/meson.build
+++ b/src/sage/schemes/meson.build
@@ -1,4 +1,9 @@
-py.install_sources('all.py', 'overview.py', subdir: 'sage/schemes')
+py.install_sources(
+ '__init__.py',
+ 'all.py',
+ 'overview.py',
+ subdir: 'sage/schemes',
+)
install_subdir('affine', install_dir: sage_install_dir / 'schemes')
install_subdir('berkovich', install_dir: sage_install_dir / 'schemes')
diff --git a/src/sage/schemes/plane_conics/con_field.py b/src/sage/schemes/plane_conics/con_field.py
old mode 100755
new mode 100644
diff --git a/src/sage/schemes/plane_conics/con_finite_field.py b/src/sage/schemes/plane_conics/con_finite_field.py
old mode 100755
new mode 100644
diff --git a/src/sage/schemes/plane_conics/con_number_field.py b/src/sage/schemes/plane_conics/con_number_field.py
old mode 100755
new mode 100644
diff --git a/src/sage/schemes/plane_conics/con_rational_field.py b/src/sage/schemes/plane_conics/con_rational_field.py
old mode 100755
new mode 100644
diff --git a/src/sage/schemes/plane_conics/con_rational_function_field.py b/src/sage/schemes/plane_conics/con_rational_function_field.py
old mode 100755
new mode 100644
diff --git a/src/sage/schemes/plane_conics/constructor.py b/src/sage/schemes/plane_conics/constructor.py
old mode 100755
new mode 100644
index a08089522c2..49e3f77e28e
--- a/src/sage/schemes/plane_conics/constructor.py
+++ b/src/sage/schemes/plane_conics/constructor.py
@@ -33,7 +33,7 @@
from sage.rings.number_field.number_field_base import NumberField
from sage.rings.polynomial.multi_polynomial import MPolynomial
from sage.rings.polynomial.multi_polynomial_ring import MPolynomialRing_base
-from sage.rings.polynomial.polynomial_ring import PolynomialRing_general
+from sage.rings.polynomial.polynomial_ring import PolynomialRing_generic
from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing
from sage.schemes.affine.affine_point import SchemeMorphism_point_affine
from sage.schemes.projective.projective_point import SchemeMorphism_point_projective_field
@@ -240,7 +240,7 @@ def Conic(base_field, F=None, names=None, unique=True):
return ProjectiveConic_rational_field(P2, F)
if isinstance(base_field, NumberField):
return ProjectiveConic_number_field(P2, F)
- if isinstance(base_field, FractionField_generic) and isinstance(base_field.ring(), (PolynomialRing_general, MPolynomialRing_base)):
+ if isinstance(base_field, FractionField_generic) and isinstance(base_field.ring(), (PolynomialRing_generic, MPolynomialRing_base)):
return ProjectiveConic_rational_function_field(P2, F)
return ProjectiveConic_field(P2, F)
diff --git a/src/sage/schemes/plane_quartics/quartic_constructor.py b/src/sage/schemes/plane_quartics/quartic_constructor.py
old mode 100755
new mode 100644
diff --git a/src/sage/schemes/plane_quartics/quartic_generic.py b/src/sage/schemes/plane_quartics/quartic_generic.py
old mode 100755
new mode 100644
diff --git a/src/sage/schemes/product_projective/homset.py b/src/sage/schemes/product_projective/homset.py
old mode 100755
new mode 100644
diff --git a/src/sage/schemes/product_projective/morphism.py b/src/sage/schemes/product_projective/morphism.py
old mode 100755
new mode 100644
diff --git a/src/sage/schemes/product_projective/point.py b/src/sage/schemes/product_projective/point.py
old mode 100755
new mode 100644
diff --git a/src/sage/schemes/product_projective/rational_point.py b/src/sage/schemes/product_projective/rational_point.py
old mode 100755
new mode 100644
diff --git a/src/sage/schemes/product_projective/space.py b/src/sage/schemes/product_projective/space.py
old mode 100755
new mode 100644
diff --git a/src/sage/schemes/product_projective/subscheme.py b/src/sage/schemes/product_projective/subscheme.py
old mode 100755
new mode 100644
diff --git a/src/sage/schemes/projective/proj_bdd_height.py b/src/sage/schemes/projective/proj_bdd_height.py
old mode 100755
new mode 100644
diff --git a/src/sage/schemes/projective/projective_homset.py b/src/sage/schemes/projective/projective_homset.py
old mode 100755
new mode 100644
diff --git a/src/sage/schemes/projective/projective_morphism.py b/src/sage/schemes/projective/projective_morphism.py
old mode 100755
new mode 100644
diff --git a/src/sage/schemes/projective/projective_point.py b/src/sage/schemes/projective/projective_point.py
old mode 100755
new mode 100644
diff --git a/src/sage/schemes/projective/projective_rational_point.py b/src/sage/schemes/projective/projective_rational_point.py
old mode 100755
new mode 100644
diff --git a/src/sage/schemes/projective/projective_space.py b/src/sage/schemes/projective/projective_space.py
old mode 100755
new mode 100644
index 89d4f28f48b..9073faa9706
--- a/src/sage/schemes/projective/projective_space.py
+++ b/src/sage/schemes/projective/projective_space.py
@@ -100,7 +100,7 @@
from sage.rings.integer import Integer
from sage.rings.integer_ring import ZZ
from sage.rings.polynomial.multi_polynomial_ring import MPolynomialRing_base
-from sage.rings.polynomial.polynomial_ring import PolynomialRing_general
+from sage.rings.polynomial.polynomial_ring import PolynomialRing_generic
from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing
from sage.rings.rational_field import QQ, RationalField
from sage.schemes.generic.ambient_space import AmbientSpace
@@ -248,7 +248,7 @@ def ProjectiveSpace(n, R=None, names=None):
sage: P.gens() == R.gens()
True
"""
- if isinstance(n, (MPolynomialRing_base, PolynomialRing_general)) and R is None:
+ if isinstance(n, (MPolynomialRing_base, PolynomialRing_generic)) and R is None:
if names is not None:
# Check for the case that the user provided a variable name
# That does not match what we wanted to use from R
diff --git a/src/sage/schemes/projective/projective_subscheme.py b/src/sage/schemes/projective/projective_subscheme.py
old mode 100755
new mode 100644
diff --git a/src/sage/schemes/riemann_surfaces/riemann_surface.py b/src/sage/schemes/riemann_surfaces/riemann_surface.py
old mode 100755
new mode 100644
diff --git a/src/sage/schemes/toric/chow_group.py b/src/sage/schemes/toric/chow_group.py
old mode 100755
new mode 100644
diff --git a/src/sage/schemes/toric/divisor.py b/src/sage/schemes/toric/divisor.py
old mode 100755
new mode 100644
diff --git a/src/sage/schemes/toric/divisor_class.pyx b/src/sage/schemes/toric/divisor_class.pyx
old mode 100755
new mode 100644
diff --git a/src/sage/schemes/toric/fano_variety.py b/src/sage/schemes/toric/fano_variety.py
old mode 100755
new mode 100644
index fcf5d03d476..fb8265818bd
--- a/src/sage/schemes/toric/fano_variety.py
+++ b/src/sage/schemes/toric/fano_variety.py
@@ -129,7 +129,7 @@
from sage.rings.rational_field import QQ
from sage.rings.polynomial.multi_polynomial_ring import MPolynomialRing_base
-from sage.rings.polynomial.polynomial_ring import PolynomialRing_general
+from sage.rings.polynomial.polynomial_ring import PolynomialRing_generic
from sage.rings.fraction_field import FractionField_generic
from sage.schemes.toric.toric_subscheme import AlgebraicScheme_subscheme_toric
@@ -1583,7 +1583,7 @@ def add_variables(field, variables):
if isinstance(field, FractionField_generic):
# Q(a) ---> Q(a, b) rather than Q(a)(b)
R = field.ring()
- if isinstance(R, (PolynomialRing_general, MPolynomialRing_base)):
+ if isinstance(R, (PolynomialRing_generic, MPolynomialRing_base)):
new_variables = list(R.variable_names())
for v in variables:
if v not in new_variables:
diff --git a/src/sage/schemes/toric/homset.py b/src/sage/schemes/toric/homset.py
old mode 100755
new mode 100644
diff --git a/src/sage/schemes/toric/ideal.py b/src/sage/schemes/toric/ideal.py
old mode 100755
new mode 100644
diff --git a/src/sage/schemes/toric/library.py b/src/sage/schemes/toric/library.py
old mode 100755
new mode 100644
diff --git a/src/sage/schemes/toric/meson.build b/src/sage/schemes/toric/meson.build
index d9dea45fcc8..0e85031ccf5 100644
--- a/src/sage/schemes/toric/meson.build
+++ b/src/sage/schemes/toric/meson.build
@@ -1,4 +1,5 @@
py.install_sources(
+ '__init__.py',
'all.py',
'chow_group.py',
'divisor.py',
diff --git a/src/sage/schemes/toric/morphism.py b/src/sage/schemes/toric/morphism.py
old mode 100755
new mode 100644
diff --git a/src/sage/schemes/toric/points.py b/src/sage/schemes/toric/points.py
old mode 100755
new mode 100644
diff --git a/src/sage/schemes/toric/sheaf/constructor.py b/src/sage/schemes/toric/sheaf/constructor.py
old mode 100755
new mode 100644
diff --git a/src/sage/schemes/toric/sheaf/klyachko.py b/src/sage/schemes/toric/sheaf/klyachko.py
old mode 100755
new mode 100644
diff --git a/src/sage/schemes/toric/toric_subscheme.py b/src/sage/schemes/toric/toric_subscheme.py
old mode 100755
new mode 100644
diff --git a/src/sage/schemes/toric/variety.py b/src/sage/schemes/toric/variety.py
old mode 100755
new mode 100644
diff --git a/src/sage/schemes/toric/weierstrass.py b/src/sage/schemes/toric/weierstrass.py
old mode 100755
new mode 100644
diff --git a/src/sage/schemes/toric/weierstrass_covering.py b/src/sage/schemes/toric/weierstrass_covering.py
old mode 100755
new mode 100644
diff --git a/src/sage/schemes/toric/weierstrass_higher.py b/src/sage/schemes/toric/weierstrass_higher.py
old mode 100755
new mode 100644
diff --git a/src/sage/sets/meson.build b/src/sage/sets/meson.build
index 73faddaf9c7..92d4cb4cd17 100644
--- a/src/sage/sets/meson.build
+++ b/src/sage/sets/meson.build
@@ -1,4 +1,5 @@
py.install_sources(
+ '__init__.py',
'all.py',
'all__sagemath_objects.py',
'cartesian_product.py',
diff --git a/src/sage/stats/distributions/meson.build b/src/sage/stats/distributions/meson.build
index 129d5f74d13..db152755b95 100644
--- a/src/sage/stats/distributions/meson.build
+++ b/src/sage/stats/distributions/meson.build
@@ -1,4 +1,5 @@
py.install_sources(
+ '__init__.py',
'all.py',
'catalog.py',
'dgs.pxd',
diff --git a/src/sage/stats/hmm/meson.build b/src/sage/stats/hmm/meson.build
index cbf4a30caa5..661c578252e 100644
--- a/src/sage/stats/hmm/meson.build
+++ b/src/sage/stats/hmm/meson.build
@@ -1,4 +1,5 @@
py.install_sources(
+ '__init__.py',
'all.py',
'distributions.pxd',
'hmm.pxd',
diff --git a/src/sage/stats/meson.build b/src/sage/stats/meson.build
index 414a909270c..52c4b684ac4 100644
--- a/src/sage/stats/meson.build
+++ b/src/sage/stats/meson.build
@@ -1,4 +1,5 @@
py.install_sources(
+ '__init__.py',
'all.py',
'basic_stats.py',
'intlist.pxd',
diff --git a/src/sage/stats/time_series.pyx b/src/sage/stats/time_series.pyx
index 28318238a25..edcc8e39ea1 100644
--- a/src/sage/stats/time_series.pyx
+++ b/src/sage/stats/time_series.pyx
@@ -465,7 +465,7 @@ cdef class TimeSeries:
"""
cdef Py_ssize_t i
cdef TimeSeries t = new_time_series(self._length)
- memcpy(t._values, self._values , sizeof(double)*self._length)
+ memcpy(t._values, self._values, sizeof(double)*self._length)
return t
def __add__(left, right):
diff --git a/src/sage/symbolic/ginac/numeric.cpp b/src/sage/symbolic/ginac/numeric.cpp
index e973390ffa2..02b07296193 100644
--- a/src/sage/symbolic/ginac/numeric.cpp
+++ b/src/sage/symbolic/ginac/numeric.cpp
@@ -3665,7 +3665,7 @@ const numeric numeric::log(const numeric &b, PyObject* parent) const {
}
// General log
-// Handle special cases here that return MPZ/MPQ
+// Handle special cases here that return MPZ/MPQ (or an infinity)
const numeric numeric::ratlog(const numeric &b, bool& israt) const {
israt = true;
if (b.is_one()) {
@@ -3688,6 +3688,9 @@ const numeric numeric::ratlog(const numeric &b, bool& israt) const {
israt = false;
return *_num0_p;
}
+ if (v._long == 0) {
+ return py_funcs.py_eval_neg_infinity();
+ }
int c = 0;
std::ldiv_t ld;
ld.quot = v._long;
diff --git a/src/sage/symbolic/meson.build b/src/sage/symbolic/meson.build
index 0ba39cb4d45..fc1f2a806e3 100644
--- a/src/sage/symbolic/meson.build
+++ b/src/sage/symbolic/meson.build
@@ -2,6 +2,7 @@ inc_ginac = include_directories('ginac')
inc_pynac = include_directories('.')
py.install_sources(
+ '__init__.py',
'all.py',
'assumptions.py',
'benchmark.py',
diff --git a/src/sage/symbolic/ring.pyx b/src/sage/symbolic/ring.pyx
index 96f3a445e9c..eaaa5cbdc15 100644
--- a/src/sage/symbolic/ring.pyx
+++ b/src/sage/symbolic/ring.pyx
@@ -207,7 +207,7 @@ cdef class SymbolicRing(sage.rings.abc.SymbolicRing):
return False
else:
from sage.rings.fraction_field import FractionField_generic
- from sage.rings.polynomial.polynomial_ring import PolynomialRing_general
+ from sage.rings.polynomial.polynomial_ring import PolynomialRing_generic
from sage.rings.polynomial.multi_polynomial_ring import MPolynomialRing_base
from sage.rings.polynomial.laurent_polynomial_ring_base import LaurentPolynomialRing_generic
from sage.rings.infinity import InfinityRing, UnsignedInfinityRing
@@ -219,7 +219,7 @@ cdef class SymbolicRing(sage.rings.abc.SymbolicRing):
if R._is_numerical():
# Almost anything with a coercion into any precision of CC
return R not in (RLF, CLF)
- elif isinstance(R, PolynomialRing_general) or isinstance(R, MPolynomialRing_base) or isinstance(R, FractionField_generic) or isinstance(R, LaurentPolynomialRing_generic):
+ elif isinstance(R, (PolynomialRing_generic, MPolynomialRing_base, FractionField_generic, LaurentPolynomialRing_generic)):
base = R.base_ring()
return base is not self and self.has_coerce_map_from(base)
elif (R is InfinityRing or R is UnsignedInfinityRing
diff --git a/src/sage/tensor/modules/comp.py b/src/sage/tensor/modules/comp.py
index 32ac954c7b4..f52cdfb744b 100644
--- a/src/sage/tensor/modules/comp.py
+++ b/src/sage/tensor/modules/comp.py
@@ -1688,7 +1688,7 @@ def __sub__(self, other):
"""
if isinstance(other, (int, Integer)) and other == 0:
return +self
- return self + (-other) #!# correct, deals properly with
+ return self + (-other) # ! # correct, deals properly with
# symmetries, but is probably not optimal
def __rsub__(self, other):
diff --git a/src/sage/version.py b/src/sage/version.py
index 1740a25851c..73436924039 100644
--- a/src/sage/version.py
+++ b/src/sage/version.py
@@ -1,5 +1,5 @@
# Sage version information for Python scripts
# This file is auto-generated by the sage-update-version script, do not edit!
-version = '10.6.beta1'
-date = '2024-12-15'
-banner = 'SageMath version 10.6.beta1, Release Date: 2024-12-15'
+version = '10.6.beta2'
+date = '2024-12-22'
+banner = 'SageMath version 10.6.beta2, Release Date: 2024-12-22'
diff --git a/src/sage_docbuild/conf.py b/src/sage_docbuild/conf.py
index d90c2eb2dd1..6c8f2d923e9 100644
--- a/src/sage_docbuild/conf.py
+++ b/src/sage_docbuild/conf.py
@@ -670,6 +670,7 @@ def linkcode_resolve(domain, info):
# used when building html version
pngmath_latex_preamble += macro + '\n'
+
# ------------------------------------------
# add custom context variables for templates
# ------------------------------------------
@@ -712,10 +713,12 @@ def add_page_context(app, pagename, templatename, context, doctree):
dangling_debug = False
+
def debug_inf(app, message):
if dangling_debug:
app.info(message)
+
def call_intersphinx(app, env, node, contnode):
r"""
Call intersphinx and make links between Sage manuals relative.
@@ -749,6 +752,7 @@ def call_intersphinx(app, env, node, contnode):
debug_inf(app, "---- Intersphinx: %s not Found" % node['reftarget'])
return res
+
def find_sage_dangling_links(app, env, node, contnode):
r"""
Try to find dangling link in local module imports or all.py.
@@ -859,6 +863,7 @@ def find_sage_dangling_links(app, env, node, contnode):
'__builtin__',
]
+
def check_nested_class_picklability(app, what, name, obj, skip, options):
"""
Print a warning if pickling is broken for nested classes.
@@ -879,6 +884,7 @@ def check_nested_class_picklability(app, what, name, obj, skip, options):
'sage.misc.nested_class.NestedClassMetaclass.' % (
v.__module__ + '.' + name + '.' + nm))
+
def skip_member(app, what, name, obj, skip, options):
"""
To suppress Sphinx warnings / errors, we
diff --git a/src/sage_docbuild/ext/sage_autodoc.py b/src/sage_docbuild/ext/sage_autodoc.py
index 6f048222437..94e7d076fa9 100644
--- a/src/sage_docbuild/ext/sage_autodoc.py
+++ b/src/sage_docbuild/ext/sage_autodoc.py
@@ -81,8 +81,12 @@
is_function_or_cython_function)
_getdoc = getdoc
+
+
def getdoc(obj, *args, **kwargs):
return sage_getdoc_original(obj)
+
+
# ------------------------------------------------------------------
if TYPE_CHECKING:
@@ -1616,7 +1620,7 @@ def can_document_member(
try:
result_bool = isinstance(member, type) or (
isattr and isinstance(member, NewType | TypeVar))
- except:
+ except Exception:
result_bool = isinstance(member, type) or (
isattr and (inspect.isNewType(member) or isinstance(member, TypeVar)))
return result_bool
@@ -1695,7 +1699,7 @@ def import_object(self, raiseerror: bool = False) -> bool:
# support both sphinx 8 and py3.9/older sphinx
try:
test_bool = isinstance(self.object, NewType | TypeVar)
- except:
+ except Exception:
test_bool = inspect.isNewType(self.object) or isinstance(self.object, TypeVar)
if test_bool:
modname = getattr(self.object, '__module__', self.modname)
@@ -1709,7 +1713,7 @@ def _get_signature(self) -> tuple[Any | None, str | None, Signature | None]:
# support both sphinx 8 and py3.9/older sphinx
try:
test_bool = isinstance(self.object, NewType | TypeVar)
- except:
+ except Exception:
test_bool = inspect.isNewType(self.object) or isinstance(self.object, TypeVar)
if test_bool:
# Suppress signature
@@ -1899,7 +1903,7 @@ def add_directive_header(self, sig: str) -> None:
# support both sphinx 8 and py3.9/older sphinx
try:
test_bool = isinstance(self.object, NewType | TypeVar)
- except:
+ except Exception:
test_bool = inspect.isNewType(self.object) or isinstance(self.object, TypeVar)
if test_bool:
return
@@ -1911,7 +1915,7 @@ def add_directive_header(self, sig: str) -> None:
# support both sphinx 8 and py3.9/older sphinx
try:
newtype_test = isinstance(self.object, NewType)
- except:
+ except Exception:
newtype_test = inspect.isNewType(self.object)
if (not self.doc_as_attr and not newtype_test
and canonical_fullname and self.fullname != canonical_fullname):
@@ -2053,7 +2057,7 @@ def add_content(self, more_content: StringList | None) -> None:
# support both sphinx 8 and py3.9/older sphinx
try:
newtype_test = isinstance(self.object, NewType)
- except:
+ except Exception:
newtype_test = inspect.isNewType(self.object)
if newtype_test:
if self.config.autodoc_typehints_format == "short":
diff --git a/src/sage_setup/autogen/interpreters/internal/instructions.py b/src/sage_setup/autogen/interpreters/internal/instructions.py
index aad7583196d..475c312b274 100644
--- a/src/sage_setup/autogen/interpreters/internal/instructions.py
+++ b/src/sage_setup/autogen/interpreters/internal/instructions.py
@@ -385,6 +385,7 @@ def instr_funcall_1arg_mpfr(name, io, op):
"""
return InstrSpec(name, io, code='%s(o0, i0, MPFR_RNDN);' % op)
+
def instr_funcall_2args_mpc(name, io, op):
r"""
A helper function for creating MPC instructions with two inputs
@@ -400,6 +401,7 @@ def instr_funcall_2args_mpc(name, io, op):
"""
return InstrSpec(name, io, code='%s(o0, i0, i1, MPC_RNDNN);' % op)
+
def instr_funcall_1arg_mpc(name, io, op):
r"""
A helper function for creating MPC instructions with one input
diff --git a/src/sage_setup/autogen/interpreters/internal/memory.py b/src/sage_setup/autogen/interpreters/internal/memory.py
index 801596e98c8..54710efd6a3 100644
--- a/src/sage_setup/autogen/interpreters/internal/memory.py
+++ b/src/sage_setup/autogen/interpreters/internal/memory.py
@@ -36,7 +36,7 @@ def string_of_addr(a):
"""
if isinstance(a, int):
return str(a)
- assert(isinstance(a, MemoryChunk))
+ assert isinstance(a, MemoryChunk)
return '*%s++' % a.name
diff --git a/src/sage_setup/autogen/interpreters/internal/specs/cc.py b/src/sage_setup/autogen/interpreters/internal/specs/cc.py
index cc42a6defab..569ebc633c9 100644
--- a/src/sage_setup/autogen/interpreters/internal/specs/cc.py
+++ b/src/sage_setup/autogen/interpreters/internal/specs/cc.py
@@ -101,6 +101,7 @@ def pass_call_c_argument(self):
"""
return "result"
+
class CCInterpreter(StackInterpreter):
r"""
A subclass of StackInterpreter, specifying an interpreter over
diff --git a/src/sage_setup/autogen/interpreters/internal/storage.py b/src/sage_setup/autogen/interpreters/internal/storage.py
index ce77abbe586..76c4f06e06f 100644
--- a/src/sage_setup/autogen/interpreters/internal/storage.py
+++ b/src/sage_setup/autogen/interpreters/internal/storage.py
@@ -852,6 +852,7 @@ def assign_c_from_py(self, c, py):
ty_mpfr = StorageTypeMPFR()
+
class StorageTypeMPC(StorageTypeAutoReference):
r"""
StorageTypeMPC is a subtype of StorageTypeAutoReference that deals
diff --git a/src/sage_setup/command/sage_build_cython.py b/src/sage_setup/command/sage_build_cython.py
index f4b1357c543..880ce7383e2 100644
--- a/src/sage_setup/command/sage_build_cython.py
+++ b/src/sage_setup/command/sage_build_cython.py
@@ -49,6 +49,7 @@
if DEVEL:
extra_compile_args.append('-ggdb')
+
class sage_build_cython(Command):
name = 'build_cython'
description = "compile Cython extensions into C/C++ extensions"
diff --git a/src/sage_setup/command/sage_build_ext.py b/src/sage_setup/command/sage_build_ext.py
index a9c5a87a673..5ef452316f0 100644
--- a/src/sage_setup/command/sage_build_ext.py
+++ b/src/sage_setup/command/sage_build_ext.py
@@ -15,6 +15,7 @@
from distutils.errors import DistutilsSetupError
from sage_setup.run_parallel import execute_list_of_commands
+
class sage_build_ext(build_ext):
def finalize_options(self):
build_ext.finalize_options(self)
diff --git a/src/sage_setup/excepthook.py b/src/sage_setup/excepthook.py
index e5206d9c082..a40cf7cec4d 100644
--- a/src/sage_setup/excepthook.py
+++ b/src/sage_setup/excepthook.py
@@ -1,6 +1,7 @@
import os
import sys
+
def excepthook(*exc):
"""
When an error occurs, display an error message similar to the error
diff --git a/src/sage_setup/find.py b/src/sage_setup/find.py
index e00336b3443..fa963c2a124 100644
--- a/src/sage_setup/find.py
+++ b/src/sage_setup/find.py
@@ -172,6 +172,7 @@ def find_python_sources(src_dir, modules=['sage'], distributions=None,
os.chdir(cwd)
return python_packages, python_modules, cython_modules
+
def filter_cython_sources(src_dir, distributions, exclude_distributions=None):
"""
Find all Cython modules in the given source directory that belong to the
@@ -221,6 +222,7 @@ def filter_cython_sources(src_dir, distributions, exclude_distributions=None):
return files
+
def _cythonized_dir(src_dir=None, editable_install=None):
"""
Return the path where Cython-generated files are placed by the build system.
@@ -343,6 +345,7 @@ def find_extra_files(src_dir, modules, cythonized_dir, special_filenames=[], *,
return data_files
+
def installed_files_by_module(site_packages, modules=('sage',)):
"""
Find all currently installed files
diff --git a/src/sage_setup/run_parallel.py b/src/sage_setup/run_parallel.py
index 5e25cd1b6a6..a920f4070e8 100644
--- a/src/sage_setup/run_parallel.py
+++ b/src/sage_setup/run_parallel.py
@@ -22,6 +22,7 @@
keep_going = False
+
def run_command(cmd):
"""
INPUT:
@@ -35,6 +36,7 @@ def run_command(cmd):
sys.stdout.flush()
return os.system(cmd)
+
def apply_func_progress(p):
"""
Given a triple p consisting of a function, value and a string,
@@ -49,6 +51,7 @@ def apply_func_progress(p):
sys.stdout.flush()
return p[0](p[1])
+
def execute_list_of_commands_in_parallel(command_list, nthreads):
"""
Execute the given list of commands, possibly in parallel, using
@@ -83,6 +86,7 @@ def execute_list_of_commands_in_parallel(command_list, nthreads):
pool.join()
process_command_results(result)
+
def process_command_results(result_values):
error = None
for r in result_values:
@@ -94,6 +98,7 @@ def process_command_results(result_values):
if error:
sys.exit(1)
+
def execute_list_of_commands(command_list):
"""
INPUT:
@@ -124,10 +129,10 @@ def execute_list_of_commands(command_list):
nthreads = min(len(command_list), nthreads)
nthreads = max(1, nthreads)
- def plural(n,noun):
+ def plural(n, noun):
if n == 1:
return "1 %s" % noun
- return "%i %ss" % (n,noun)
+ return "%i %ss" % (n, noun)
print("Executing %s (using %s)" % (plural(len(command_list),"command"), plural(nthreads,"thread")))
execute_list_of_commands_in_parallel(command_list, nthreads)
diff --git a/src/sage_setup/setenv.py b/src/sage_setup/setenv.py
index 48a38afad74..e7ad6552440 100644
--- a/src/sage_setup/setenv.py
+++ b/src/sage_setup/setenv.py
@@ -4,6 +4,7 @@
import platform
from pathlib import Path
+
def _environ_prepend(var, value, separator=':'):
if value:
if var in os.environ:
@@ -11,6 +12,7 @@ def _environ_prepend(var, value, separator=':'):
else:
os.environ[var] = value
+
def setenv():
from sage.env import SAGE_LOCAL, SAGE_VENV, SAGE_ARCHFLAGS, SAGE_PKG_CONFIG_PATH
diff --git a/tools/update-meson.py b/tools/update-meson.py
index 827b7d9b5a3..1a53ac21397 100755
--- a/tools/update-meson.py
+++ b/tools/update-meson.py
@@ -86,9 +86,6 @@ def update_python_sources(self: Rewriter, visitor: AstPython):
to_append: list[StringNode] = []
for file in python_files:
file_name = file.name
- if file_name == "__init__.py":
- # We don't want to add __init__.py files
- continue
if file_name in src_list:
continue
token = Token("string", target.filename, 0, 0, 0, None, file_name)