~comcloudway/ccw-aports

fa7e16fbb05e671b8c97ca05e9e95bec1deddda5 — Jakob Meier 2 years ago 1c651f5
Templated from aur-sagemath-git

https://aur.archlinux.org/sagemath-git.git
A sagemath-git/PKGBUILD => sagemath-git/PKGBUILD +138 -0
@@ 0,0 1,138 @@
# Maintainer: Antonio Rojas <arojas@archlinux.org>
# Contributor: Evgeniy Alekseev <arcanis.arch at gmail dot com>
# Contributor: Daniel Wallace <danielwallace at gtmanfred dot com>
# Contributor: Thomas Dziedzic <gostrc at gmail dot com>
# Contributor: Osman Ugus <ugus11 at yahoo dot com>
# Contributor: Stefan Husmann <stefan-husmann at t-online dot de>

pkgname=sagemath-git
pkgver=9.8.beta1.r0.g54cd6fe6de5
pkgrel=1
pkgdesc='Open Source Mathematics Software, free alternative to Magma, Maple, Mathematica, and Matlab'
arch=(x86_64)
url='http://www.sagemath.org'
license=(GPL)
depends=(palp brial cliquer maxima-fas gfan sympow nauty python-rpy2 python-fpylll python-cypari2
  python-matplotlib python-scipy python-sympy python-networkx python-pplpy python-sphinx python-ipywidgets python-memory-allocator
  gap flintqs lcalc lrcalc arb eclib zn_poly gd python-cvxopt singular linbox m4rie pari-galdata pari-seadata-small planarity rankwidth tachyon
  sage-data-combinatorial_designs sage-data-elliptic_curves sage-data-graphs sage-data-polytopes_db sage-data-conway_polynomials
  iml giac libhomfly libbraiding symmetrica threejs-sage python-primecountpy)
optdepends=('cython: to compile cython code'
  'python-pkgconfig: to compile cython code'
  'jmol: alternative 3D plot engine'
  'jupyter-jsmol: alternative 3D plot engine in the Jupyter notebook'
  'sagemath-doc: HTML documentation'
  'python-igraph: igraph backend for graph theory'
  'bliss: bliss backend for graph theory'
  'sage-numerical-backends-coin: COIN mixed integer linear programming backend'
  'sage-numerical-backends-gurobi: Gurobi mixed integer linear programming backend'
  'coin-or-csdp: for computing Lovász theta-function of graphs'
  'buckygen: for generating fullerene graphs'
  'plantri: for generating some classes of graphs'
  'benzene: for generating fusenes and benzenoids'
  'ffmpeg: to export animations to video'
  'imagemagick: to show animations'
  'coxeter: Coxeter groups implementation'
  'rubiks: Rubiks cube algorithms'
  'lrs: Algorithms for linear reverse search used in game theory and for computing volume of polytopes'
  'python-pynormaliz: Normaliz backend for polyhedral computations'
  'latte-integrale: integral point count in polyhedra'
  'python-jupymake: polymake backend for polyhedral computations'
  'shared_meataxe: faster matrix arithmetic over finite fields'
  'openblas: faster linear algebra'
  'sirocco: for computing the fundamental group of the complement of a plane curve'
  'dot2tex: for displaying some diagrams'
  'cryptominisat5: SAT solver'
  'python-pycosat: picosat SAT solver'
  'python-pip: to install optional packages with sage -pip'
  'sage-notebook-exporter: convert flask notebooks to Jupyter'
  'python-database-knotinfo: interface to the KnotInfo and LinkInfo databases'
  'python-phitigra: graph editor'
  'topcom: to compute triangulations of point configurations'
  'python-database-cubic-hecke: cubic Hecke algebras')
makedepends=(cython boost python-jinja sirocco mcqd coxeter bliss tdlib python-pkgconfig shared_meataxe git)
conflicts=(sagemath)
provides=(sagemath)
source=(git://git.sagemath.org/sage.git#branch=develop
        sagemath-optional-packages.patch
        latte-count.patch
        test-optional.patch
        sagemath-linbox-1.7.patch
        sagemath-bliss-0.77.patch
        sagemath-tachyon-0.99.patch
        sagemath-gap-4.12.patch
        sagemath-ipywidgets-8.patch
        sagemath-tdlib-0.9.patch
        sagemath-pari-2.15.patch)
sha256sums=('SKIP'
            'eee5fa15d8c7be7e009166dbde3ea24bb10d7793dc12880516f278f86b1a6694'
            'bd188af45ce31579b82407adee8e9bf6033a996f7ea6e328fabca526f31c08ba'
            '9d042070df3dfd53a1248659677798da888f733548eda91a6d5169c7aa1907e1'
            'eacea27b214d32cb886a75695153dfc36b5bad2fd2517e8e4eee18e74220e9e3'
            '3e1f866944235b999d2d727ed1ced431bd67405b053701c21068607ec76f23c3'
            '9760db6c6ec40cc16ab8a0cbf3d019df7f6a69ff292e35622f282b7c888aac77'
            '89e9ade86131a5989ae2f2c2cee6a12f2c71df35d1ef7a84d6176dd3de0f2889'
            'bdf56f85b608da12074780271ae134b02a03278f7b53a183f6dd97d8d72073e0'
            '56a83abecf2ff5a500442adc7a50abbb70006037dd39c39dcdb04b3ca9fb51e2'
            '8a1d802b1916c5a7d9b1cdde3e46a79e44f1b10a9d70be1f1885ce84406faa01')

pkgver() {
  cd sage
  git describe --long --tags | sed -r 's/([^-]*-g)/r\1/;s/-/./g'
}

prepare(){
  cd sage

# Upstream patches
# Fix build with linbox 1.7 https://trac.sagemath.org/ticket/32959
  patch -p1 -i ../sagemath-linbox-1.7.patch
# Fix build with bliss 0.77 https://trac.sagemath.org/ticket/33010
  patch -p1 -i ../sagemath-bliss-0.77.patch
# Fix tests with tachyon 0.99 https://trac.sagemath.org/ticket/23712
  patch -p1 -i ../sagemath-tachyon-0.99.patch
# Port to GAP 4.12 https://trac.sagemath.org/ticket/34391
  patch -p1 -i ../sagemath-gap-4.12.patch
# Fixes for ipywidgets 8 https://trac.sagemath.org/ticket/34460
  patch -p1 -i ../sagemath-ipywidgets-8.patch
# Update to PARI 2.15 https://trac.sagemath.org/ticket/34537
  patch -p1 -i ../sagemath-pari-2.15.patch

# Arch-specific patches
# assume all optional packages are installed
  patch -p1 -i ../sagemath-optional-packages.patch
# don't list optional packages when running tests
  patch -p1 -i ../test-optional.patch
# use correct latte-count binary name
  patch -p1 -i ../latte-count.patch
# update to tdlib 0.9 (Fedora)
  patch -p1 -i ../sagemath-tdlib-0.9.patch

  cd build/pkgs/sagelib
  ./bootstrap
}

build() {
  cd sage/pkgs/sagemath-standard

  export SAGE_NUM_THREADS=10
  export PYTHONPATH="$PWD"/../sage-setup
  python setup.py build
}

package() {
  cd sage/pkgs/sagemath-standard

  python setup.py install --root="$pkgdir" --optimize=1

# fix symlinks to assets
  _pythonpath=`python -c "from sysconfig import get_path; print(get_path('platlib'))"`
  for _i in $(ls "$srcdir"/sage/src/sage/ext_data/notebook-ipython); do
    rm "$pkgdir"/usr/share/jupyter/kernels/sagemath/$_i
    ln -s $_pythonpath/sage/ext_data/notebook-ipython/$_i "$pkgdir"/usr/share/jupyter/kernels/sagemath/
  done

# adjust threejs version
  rm "$pkgdir"$_pythonpath/sage/ext_data/threejs/threejs-version.txt
  ln -s /usr/share/threejs-sage/version "$pkgdir"$_pythonpath/sage/ext_data/threejs/threejs-version.txt
}

A sagemath-git/latte-count.patch => sagemath-git/latte-count.patch +14 -0
@@ 0,0 1,14 @@
diff --git a/src/sage/features/latte.py b/src/sage/features/latte.py
index 63d227fd35..040a5cf1f9 100644
--- a/src/sage/features/latte.py
+++ b/src/sage/features/latte.py
@@ -21,7 +21,7 @@ from . import Executable, Feature, FeatureTestResult
             sage: isinstance(Latte_count(), Latte_count)
             True
         """
-        Executable.__init__(self, "count", executable="count",
+        Executable.__init__(self, "latte-count", executable="latte-count",
                             spkg="latte_int",
                             url=LATTE_URL)
 


A sagemath-git/sagemath-bliss-0.77.patch => sagemath-git/sagemath-bliss-0.77.patch +176 -0
@@ 0,0 1,176 @@
diff --git a/build/pkgs/bliss/checksums.ini b/build/pkgs/bliss/checksums.ini
index e97d89587b..0c1ebf647b 100644
--- a/build/pkgs/bliss/checksums.ini
+++ b/build/pkgs/bliss/checksums.ini
@@ -1,4 +1,5 @@
-tarball=bliss-VERSION.tar.gz
-sha1=1da8f098046824fbfff4c64c337e28b2a082f74f
-md5=452aea8737d3c4ad0d8ff39180be8004
-cksum=2193930007
+tarball=bliss-VERSION.zip
+sha1=c91c9dcbc11d66ffbcf6415e09ebe793df37be2a
+md5=5707cbfd9fd00980571c64ab3584c505
+cksum=1626493724
+upstream_url=https://users.aalto.fi/~tjunttil/bliss/downloads/bliss-VERSION.zip
diff --git a/build/pkgs/bliss/dependencies b/build/pkgs/bliss/dependencies
index 4f00de2037..c225c495cc 100644
--- a/build/pkgs/bliss/dependencies
+++ b/build/pkgs/bliss/dependencies
@@ -1,4 +1,4 @@
-# no dependencies
+| cmake
 
 ----------
 All lines of this file are ignored except the first.
diff --git a/build/pkgs/bliss/package-version.txt b/build/pkgs/bliss/package-version.txt
index e93ee1376f..9e1e206c41 100644
--- a/build/pkgs/bliss/package-version.txt
+++ b/build/pkgs/bliss/package-version.txt
@@ -1 +1 @@
-0.73+debian-1+sage-2016-08-02.p0
+0.77
diff --git a/build/pkgs/bliss/spkg-install.in b/build/pkgs/bliss/spkg-install.in
index aaf4c3037b..4124a2338e 100644
--- a/build/pkgs/bliss/spkg-install.in
+++ b/build/pkgs/bliss/spkg-install.in
@@ -1,4 +1,4 @@
 cd src
-sdh_configure --disable-gmp
+sdh_cmake -DUSE_GMP=OFF -DCMAKE_VERBOSE_MAKEFILE=ON
 sdh_make
 sdh_make_install
diff --git a/build/pkgs/bliss/spkg-src b/build/pkgs/bliss/spkg-src
deleted file mode 100755
index 90073233b7..0000000000
--- a/build/pkgs/bliss/spkg-src
+++ /dev/null
@@ -1,28 +0,0 @@
-#!/bin/sh
-#
-# creates the tarball in the current dir, to be moved to ../../../upstream
-#
-# adapted from cliquer/spkg-src
-
-die () {
-    echo >&2 "$@"
-    exit 1
-}
-
-rm -rf bliss/
-git clone -b sage_package https://github.com/mkoeppe/bliss.git  || die "Failed to git clone"
-cd bliss/
-
-VERSION=`autoconf --trace='AC_INIT:$2'`
-libtoolize || die "Failed to autoreconf"
-autoreconf -fi || die "Failed to autoreconf"
-automake --add-missing --copy || die "automake failed"
-./configure || die "configure failed"
-
-rm -f bliss-$VERSION.tar.gz
-make dist || die "make dist failed"
-mv bliss-$VERSION.tar.gz ../
-cd ..
-rm -rf bliss/
-
-
diff --git a/src/sage/graphs/bliss.pyx b/src/sage/graphs/bliss.pyx
index 921bc6a765..1f1f502558 100644
--- a/src/sage/graphs/bliss.pyx
+++ b/src/sage/graphs/bliss.pyx
@@ -47,22 +47,23 @@ cdef extern from "bliss/graph.hh" namespace "bliss":
     cdef cppclass Graph(AbstractGraph):
         Graph(const unsigned int)
         void add_edge(const unsigned int, const unsigned int)
-        void find_automorphisms(Stats&, void (*)(void*, unsigned int,
-                                                 const unsigned int*), void*)
         void change_color(const unsigned int, const unsigned int)
-        const unsigned int* canonical_form(Stats&, void (*)(void*, unsigned int,
-                                                            const unsigned int*), void*)
+        const unsigned int* canonical_form(Stats&)
+
+cdef extern from "bliss/digraph.hh" namespace "bliss":
 
     cdef cppclass Digraph(AbstractGraph):
         Digraph(const unsigned int)
         void add_edge(const unsigned int, const unsigned int)
-        void find_automorphisms(Stats&, void (*)(void*, unsigned int,
-                                                 const unsigned int*), void*)
         void change_color(const unsigned int, const unsigned int)
-        const unsigned int* canonical_form(Stats&, void (*)(void*, unsigned int,
-                                                            const unsigned int*), void*)
+        const unsigned int* canonical_form(Stats&)
         unsigned int get_hash()
 
+cdef extern from "bliss_find_automorphisms.h":
+
+    void bliss_find_automorphisms(Graph*, void (*)(void*, unsigned int, const unsigned int*), void*, Stats&)
+    void bliss_find_automorphisms(Digraph*, void (*)(void*, unsigned int, const unsigned int*), void*, Stats&)
+
 
 cdef int encoding_numbits(int n):
     r"""
@@ -124,9 +125,6 @@ cdef void add_gen(void *user_param, unsigned int n, const unsigned int *aut):
 
     sig_free(done)
 
-cdef void empty_hook(void *user_param, unsigned int n, const unsigned int *aut):
-    return
-
 #####################################################
 # constructing bliss graphs from edge lists
 #####################################################
@@ -345,10 +343,10 @@ cdef canonical_form_from_edge_list(int Vnr, list Vout, list Vin, int Lnr=1, list
 
     if directed:
         d = bliss_digraph_from_labelled_edges(Vnr, Lnr, Vout, Vin, labels, partition)
-        aut = d.canonical_form(s, empty_hook, NULL)
+        aut = d.canonical_form(s)
     else:
         g = bliss_graph_from_labelled_edges(Vnr, Lnr, Vout, Vin, labels, partition)
-        aut = g.canonical_form(s, empty_hook, NULL)
+        aut = g.canonical_form(s)
 
     for i in range(len(Vout)):
         x = Vout[i]
@@ -640,11 +638,11 @@ cdef automorphism_group_gens_from_edge_list(int Vnr, Vout, Vin, int Lnr=1, label
 
     if directed:
         d = bliss_digraph_from_labelled_edges(Vnr, Lnr, Vout, Vin, labels, partition)
-        d.find_automorphisms(s, add_gen, <void*>data)
+        bliss_find_automorphisms(d, add_gen, <void*>data, s)
         del d
     else:
         g = bliss_graph_from_labelled_edges(Vnr, Lnr, Vout, Vin, labels, partition)
-        g.find_automorphisms(s, add_gen, <void*>data)
+        bliss_find_automorphisms(g, add_gen, <void*>data, s)
         del g
 
     return [[cyc for cyc in gen if cyc[0] is not None] for gen in gens]
diff --git a/src/sage/graphs/bliss_find_automorphisms.h b/src/sage/graphs/bliss_find_automorphisms.h
new file mode 100644
index 0000000000..a2c084a163
--- /dev/null
+++ b/src/sage/graphs/bliss_find_automorphisms.h
@@ -0,0 +1,22 @@
+#include <bliss/graph.hh>
+#include <bliss/digraph.hh>
+
+inline void bliss_find_automorphisms(bliss::Graph *graph, void (*hook)(void *user_param, unsigned int n, const unsigned int *aut), void *hook_user_param, bliss::Stats s)
+{
+  auto report_aut = [&](unsigned int n, const unsigned int *aut) -> void {
+    if(hook)
+      (*hook)(hook_user_param, n, aut);
+  };
+
+  graph->find_automorphisms(s, report_aut);
+}
+
+inline void bliss_find_automorphisms(bliss::Digraph *graph, void (*hook)(void *user_param, unsigned int n, const unsigned int *aut), void *hook_user_param, bliss::Stats s)
+{
+  auto report_aut = [&](unsigned int n, const unsigned int *aut) -> void {
+    if(hook)
+      (*hook)(hook_user_param, n, aut);
+  };
+
+  graph->find_automorphisms(s, report_aut);
+}

A sagemath-git/sagemath-gap-4.12.patch => sagemath-git/sagemath-gap-4.12.patch +415 -0
@@ 0,0 1,415 @@
diff --git a/src/doc/en/thematic_tutorials/lie/weyl_groups.rst b/src/doc/en/thematic_tutorials/lie/weyl_groups.rst
index c917338e44..182e74aad2 100644
--- a/src/doc/en/thematic_tutorials/lie/weyl_groups.rst
+++ b/src/doc/en/thematic_tutorials/lie/weyl_groups.rst
@@ -139,12 +139,12 @@ string, which you can print::
     X.1      1  1  1  1  1  1  1  1  1  1  1  1  1
     X.2      1 -1  1  1 -1  1  1 -1 -1 -1  1  1  1
     X.3      2  .  2 -1  .  2  2  .  .  . -1  2  2
-    X.4      3 -1 -1  .  1 -1  3 -1  1 -1  . -1  3
-    X.5      3 -1 -1  .  1  3 -1 -1 -1  1  . -1  3
-    X.6      3  1 -1  . -1 -1  3  1 -1  1  . -1  3
-    X.7      3  1 -1  . -1  3 -1  1  1 -1  . -1  3
-    X.8      3 -1  3  . -1 -1 -1 -1  1  1  . -1  3
-    X.9      3  1  3  .  1 -1 -1  1 -1 -1  . -1  3
+    X.4      3 -1 -1  .  1  3 -1 -1 -1  1  . -1  3
+    X.5      3  1 -1  . -1  3 -1  1  1 -1  . -1  3
+    X.6      3 -1  3  . -1 -1 -1 -1  1  1  . -1  3
+    X.7      3 -1 -1  .  1 -1  3 -1  1 -1  . -1  3
+    X.8      3  1  3  .  1 -1 -1  1 -1 -1  . -1  3
+    X.9      3  1 -1  . -1 -1  3  1 -1  1  . -1  3
     X.10     4 -2  . -1  .  .  .  2  .  .  1  . -4
     X.11     4  2  . -1  .  .  . -2  .  .  1  . -4
     X.12     6  . -2  .  . -2 -2  .  .  .  .  2  6
diff --git a/src/sage/coding/codecan/autgroup_can_label.pyx b/src/sage/coding/codecan/autgroup_can_label.pyx
index de5db985e0..c83b9264e4 100644
--- a/src/sage/coding/codecan/autgroup_can_label.pyx
+++ b/src/sage/coding/codecan/autgroup_can_label.pyx
@@ -76,7 +76,7 @@ columns do share the same coloring::
     ((1,),
      (2,),
      (3, 5, 4),
-     (6, 19, 16, 9, 21, 10, 8, 15, 14, 11, 20, 13, 12, 7, 17, 18))
+     (6, 19, 16, 21, 9, 10, 15, 8, 20, 11, 14, 13, 7, 12, 18, 17))
 
 We can also restrict the group action to linear isometries::
 
diff --git a/src/sage/coding/linear_code.py b/src/sage/coding/linear_code.py
index e8e32f82c9..9d45160f44 100644
--- a/src/sage/coding/linear_code.py
+++ b/src/sage/coding/linear_code.py
@@ -466,27 +466,27 @@ class AbstractLinearCode(AbstractLinearCodeNoMetric):
             0
             sage: C = codes.HammingCode(GF(4, 'z'), 3)
             sage: C.automorphism_group_gens()
-            ([((1, 1, 1, 1, 1, z + 1, z, z + 1, z, z, z, 1, 1, z + 1, z + 1, z, z + 1, z, z + 1, z + 1, z + 1); (1,14,6,7,4,10,11,19)(2,8,16,13,3,17,21,15)(9,12,18,20), Ring endomorphism of Finite Field in z of size 2^2
+            ([((1, 1, 1, z, z + 1, 1, 1, 1, 1, z + 1, z, z, z + 1, z + 1, z + 1, 1, z + 1, z, z, 1, z); (1,13,14,20)(2,21,8,18,7,16,19,15)(3,10,5,12,17,9,6,4), Ring endomorphism of Finite Field in z of size 2^2
+                Defn: z |--> z + 1),
+              ((z, 1, z, z, z, z + 1, z, z, z, z, z, z, z + 1, z, z, z, z, z + 1, z, z, z); (1,11,5,12,3,19)(2,8)(6,18,13)(7,17,15)(9,10,14,16,20,21), Ring endomorphism of Finite Field in z of size 2^2
                 Defn: z |--> z + 1),
-              ((z + 1, 1, 1, z, z + 1, z, z, z + 1, z + 1, z + 1, 1, z + 1, z, z, 1, z + 1, 1, z, z + 1, z + 1, z); (1,18,6,19,2,9,17,10,13,14,21,11,4,5,12)(3,20,7,16,8), Ring endomorphism of Finite Field in z of size 2^2
-                Defn: z |--> z),
               ((z, z, z, z, z, z, z, z, z, z, z, z, z, z, z, z, z, z, z, z, z); (), Ring endomorphism of Finite Field in z of size 2^2
                 Defn: z |--> z)],
              362880)
             sage: C.automorphism_group_gens(equivalence="linear")
-            ([((z + 1, 1, z + 1, z + 1, z + 1, z, 1, z, 1, 1, 1, 1, z + 1, z + 1, z + 1, z, z, 1, z, z, z); (1,15,2,8,16,18,3)(4,9,12,13,20,10,11)(5,21,14,6,7,19,17), Ring endomorphism of Finite Field in z of size 2^2
+            ([((z, 1, z + 1, z + 1, 1, z + 1, z, 1, z + 1, z + 1, 1, z, 1, z + 1, z, 1, z, 1, z + 1, 1, 1); (1,12,11,10,6,8,9,20,13,21,5,14,3,16,17,19,7,4,2,15,18), Ring endomorphism of Finite Field in z of size 2^2
                 Defn: z |--> z),
-              ((z + 1, z + 1, z + 1, z + 1, z + 1, 1, z, 1, z, z, z, 1, z, 1, 1, 1, z + 1, z + 1, z + 1, 1, z); (1,15,21,8,9)(2,18,5,3,11,16,7,10,19,13,12,4,17,6,20), Ring endomorphism of Finite Field in z of size 2^2
+              ((z + 1, z + 1, z + 1, z, 1, 1, z, z, 1, z + 1, z, 1, 1, z, 1, z + 1, z, z + 1, z + 1, 1, z); (1,3,18,2,17,6,19)(4,15,13,20,7,14,16)(5,11,8,21,12,9,10), Ring endomorphism of Finite Field in z of size 2^2
                 Defn: z |--> z),
               ((z + 1, z + 1, z + 1, z + 1, z + 1, z + 1, z + 1, z + 1, z + 1, z + 1, z + 1, z + 1, z + 1, z + 1, z + 1, z + 1, z + 1, z + 1, z + 1, z + 1, z + 1); (), Ring endomorphism of Finite Field in z of size 2^2
                 Defn: z |--> z)],
              181440)
             sage: C.automorphism_group_gens(equivalence="permutational")
-            ([((1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1); (1,19)(3,17)(4,21)(5,20)(7,14)(9,12)(10,16)(11,15), Ring endomorphism of Finite Field in z of size 2^2
+            ([((1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1); (1,11)(3,10)(4,9)(5,7)(12,21)(14,20)(15,19)(16,17), Ring endomorphism of Finite Field in z of size 2^2
                 Defn: z |--> z),
-              ((1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1); (1,11)(3,10)(4,9)(5,7)(12,21)(14,20)(15,19)(16,17), Ring endomorphism of Finite Field in z of size 2^2
+              ((1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1); (2,18)(3,19)(4,10)(5,16)(8,13)(9,14)(11,21)(15,20), Ring endomorphism of Finite Field in z of size 2^2
                 Defn: z |--> z),
-              ((1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1); (1,17)(2,8)(3,14)(4,10)(7,12)(9,19)(13,18)(15,20), Ring endomorphism of Finite Field in z of size 2^2
+              ((1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1); (1,19)(3,17)(4,21)(5,20)(7,14)(9,12)(10,16)(11,15), Ring endomorphism of Finite Field in z of size 2^2
                 Defn: z |--> z),
               ((1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1); (2,13)(3,14)(4,20)(5,11)(8,18)(9,19)(10,15)(16,21), Ring endomorphism of Finite Field in z of size 2^2
                 Defn: z |--> z)],
@@ -692,10 +692,10 @@ class AbstractLinearCode(AbstractLinearCodeNoMetric):
             sage: C_iso == aut_group_can_label.get_canonical_form()
             True
             sage: aut_group_can_label.get_autom_gens()
-            [((1, 1, 1, 1, 1, z + 1, z, z + 1, z, z, z, 1, 1, z + 1, z + 1, z, z + 1, z, z + 1, z + 1, z + 1); (1,14,6,7,4,10,11,19)(2,8,16,13,3,17,21,15)(9,12,18,20), Ring endomorphism of Finite Field in z of size 2^2
+            [((1, 1, 1, z, z + 1, 1, 1, 1, 1, z + 1, z, z, z + 1, z + 1, z + 1, 1, z + 1, z, z, 1, z); (1,13,14,20)(2,21,8,18,7,16,19,15)(3,10,5,12,17,9,6,4), Ring endomorphism of Finite Field in z of size 2^2
+               Defn: z |--> z + 1),
+             ((z, 1, z, z, z, z + 1, z, z, z, z, z, z, z + 1, z, z, z, z, z + 1, z, z, z); (1,11,5,12,3,19)(2,8)(6,18,13)(7,17,15)(9,10,14,16,20,21), Ring endomorphism of Finite Field in z of size 2^2
                Defn: z |--> z + 1),
-             ((z + 1, 1, 1, z, z + 1, z, z, z + 1, z + 1, z + 1, 1, z + 1, z, z, 1, z + 1, 1, z, z + 1, z + 1, z); (1,18,6,19,2,9,17,10,13,14,21,11,4,5,12)(3,20,7,16,8), Ring endomorphism of Finite Field in z of size 2^2
-               Defn: z |--> z),
              ((z, z, z, z, z, z, z, z, z, z, z, z, z, z, z, z, z, z, z, z, z); (), Ring endomorphism of Finite Field in z of size 2^2
                Defn: z |--> z)]
         """
diff --git a/src/sage/combinat/root_system/hecke_algebra_representation.py b/src/sage/combinat/root_system/hecke_algebra_representation.py
index bde2823421..bffcc85f6e 100644
--- a/src/sage/combinat/root_system/hecke_algebra_representation.py
+++ b/src/sage/combinat/root_system/hecke_algebra_representation.py
@@ -355,7 +355,7 @@ class HeckeAlgebraRepresentation(WithEqualityById, SageObject):
             sage: q1, q2 = K.gens()
             sage: KW = W.algebra(K)
             sage: x = KW.an_element(); x
-            123 + 3*32 + 2*3 + e
+            123 + 3*2312 + 2*31 + e
 
             sage: T = KW.demazure_lusztig_operators(q1,q2)
             sage: T12 = T.Tw( (1,2) )
diff --git a/src/sage/combinat/symmetric_group_algebra.py b/src/sage/combinat/symmetric_group_algebra.py
index c3d67555a6..da953d2b01 100644
--- a/src/sage/combinat/symmetric_group_algebra.py
+++ b/src/sage/combinat/symmetric_group_algebra.py
@@ -101,7 +101,7 @@ def SymmetricGroupAlgebra(R, W, category=None):
         sage: SGA.group()
         Weyl Group of type ['A', 3] (as a matrix group acting on the ambient space)
         sage: SGA.an_element()
-        s1*s2*s3 + 3*s3*s2 + 2*s3 + 1
+        s1*s2*s3 + 3*s2*s3*s1*s2 + 2*s3*s1 + 1
 
     The preferred way to construct the symmetric group algebra is to
     go through the usual ``algebra`` method::
diff --git a/src/sage/groups/abelian_gps/abelian_group_gap.py b/src/sage/groups/abelian_gps/abelian_group_gap.py
index a4b047113c..86090b4353 100644
--- a/src/sage/groups/abelian_gps/abelian_group_gap.py
+++ b/src/sage/groups/abelian_gps/abelian_group_gap.py
@@ -338,7 +338,7 @@ class AbelianGroup_gap(UniqueRepresentation, GroupMixinLibGAP, ParentLibGAP, Abe
         if isinstance(x, AbelianGroupElement_gap):
             try:
                 if x in self._cover:
-                    x = self.gap().NaturalHomomorphism().Image(x.gap())
+                    x = self._cover.gap().NaturalHomomorphismByNormalSubgroup(self._relations).Image(x.gap())
                 else:
                     x = x.gap()
             except AttributeError:
@@ -1043,7 +1043,7 @@ class AbelianGroupQuotient_gap(AbelianGroup_gap):
             From: Abelian group with gap, generator orders (4,)
             To:   Quotient abelian group with generator orders (2,)
         """
-        phi = self.gap().NaturalHomomorphism()
+        phi = self._cover.gap().NaturalHomomorphismByNormalSubgroup(self._relations)
         Hom = self._cover.Hom(self)
         return Hom(phi)
 
diff --git a/src/sage/groups/finitely_presented.py b/src/sage/groups/finitely_presented.py
index d953022d3d..ad339b8965 100644
--- a/src/sage/groups/finitely_presented.py
+++ b/src/sage/groups/finitely_presented.py
@@ -596,9 +596,9 @@ class RewritingSystem():
             sage: k = G.rewriting_system()
             sage: k.gap()
             Knuth Bendix Rewriting System for Monoid( [ a, A, b, B ] ) with rules
-            [ [ a^2, <identity ...> ], [ a*A, <identity ...> ],
-              [ A*a, <identity ...> ], [ b^2, <identity ...> ],
-              [ b*B, <identity ...> ], [ B*b, <identity ...> ] ]
+            [ [ a*A, <identity ...> ], [ A*a, <identity ...> ],
+              [ b*B, <identity ...> ], [ B*b, <identity ...> ],
+              [ a^2, <identity ...> ], [ b^2, <identity ...> ] ]
         """
         return self._gap
 
diff --git a/src/sage/groups/fqf_orthogonal.py b/src/sage/groups/fqf_orthogonal.py
index 75de408912..dd7d84d960 100644
--- a/src/sage/groups/fqf_orthogonal.py
+++ b/src/sage/groups/fqf_orthogonal.py
@@ -143,7 +143,7 @@ class FqfOrthogonalGroup(AbelianGroupAutomorphismGroup_subgroup):
         [2/3   0   0]
         [  0 2/3   0]
         [  0   0 4/3]
-        generated by 2 elements
+        generated by 3 elements
         sage: q = matrix.diagonal(QQ, [3/2, 1/4, 1/4])
         sage: T = TorsionQuadraticForm(q)
         sage: T.orthogonal_group().order()
diff --git a/src/sage/groups/libgap_wrapper.pyx b/src/sage/groups/libgap_wrapper.pyx
index a76afc2ac9..9340c0d6c6 100644
--- a/src/sage/groups/libgap_wrapper.pyx
+++ b/src/sage/groups/libgap_wrapper.pyx
@@ -25,7 +25,7 @@ Note how we call the constructor of both superclasses to initialize
 its output via LibGAP::
 
     sage: FooGroup()
-    <pc group of size 3 with 1 generators>
+    <pc group of size 3 with 1 generator>
     sage: type(FooGroup().gap())
     <class 'sage.libs.gap.element.GapElement'>
 
@@ -106,7 +106,7 @@ class ParentLibGAP(SageObject):
         ....:         ParentLibGAP.__init__(self, lg)
         ....:         Group.__init__(self)
         sage: FooGroup()
-        <pc group of size 3 with 1 generators>
+        <pc group of size 3 with 1 generator>
     """
 
     def __init__(self, libgap_parent, ambient=None):
@@ -461,7 +461,7 @@ cdef class ElementLibGAP(MultiplicativeGroupElement):
         ....:         ParentLibGAP.__init__(self, lg)
         ....:         Group.__init__(self)
         sage: FooGroup()
-        <pc group of size 3 with 1 generators>
+        <pc group of size 3 with 1 generator>
         sage: FooGroup().gens()
         (f1,)
     """
diff --git a/src/sage/groups/matrix_gps/finitely_generated.py b/src/sage/groups/matrix_gps/finitely_generated.py
index a6d3dc0251..63956ad5f1 100644
--- a/src/sage/groups/matrix_gps/finitely_generated.py
+++ b/src/sage/groups/matrix_gps/finitely_generated.py
@@ -563,9 +563,6 @@ class FinitelyGeneratedMatrixGroup_gap(MatrixGroup_gap):
             21499084800
             sage: P = G.as_permutation_group()
             sage: Psmaller = G.as_permutation_group(algorithm="smaller", seed=6)
-            sage: P == Psmaller  # see the note below
-            True
-            sage: Psmaller = G.as_permutation_group(algorithm="smaller")
             sage: P == Psmaller
             False
             sage: P.cardinality()
diff --git a/src/sage/groups/perm_gps/partn_ref2/refinement_generic.pyx b/src/sage/groups/perm_gps/partn_ref2/refinement_generic.pyx
index f2ccca042a..47d6862333 100644
--- a/src/sage/groups/perm_gps/partn_ref2/refinement_generic.pyx
+++ b/src/sage/groups/perm_gps/partn_ref2/refinement_generic.pyx
@@ -427,7 +427,7 @@ cdef class LabelledBranching:
             sage: from sage.groups.perm_gps.partn_ref2.refinement_generic import LabelledBranching
             sage: L = LabelledBranching(3)
             sage: L.small_generating_set()
-            []
+            [()]
             sage: L.add_gen(libgap.eval('(1,2,3)'))
             sage: L.small_generating_set()
             [(1,2,3)]
diff --git a/src/sage/groups/perm_gps/permgroup.py b/src/sage/groups/perm_gps/permgroup.py
index 7723ec2526..aa60cc6874 100644
--- a/src/sage/groups/perm_gps/permgroup.py
+++ b/src/sage/groups/perm_gps/permgroup.py
@@ -927,7 +927,7 @@ class PermutationGroup_generic(FiniteGroup):
            sage: f = PG._coerce_map_from_(MG)
            sage: mg = MG.an_element()
            sage: p = f(mg); p
-           (2,33,32,23,31,55)(3,49,38,44,40,28)(4,17,59,62,58,46)(5,21,47,20,43,8)(6,53,50)(7,37,12,57,14,29)(9,41,56,34,64,10)(11,25,19)(13,61,26,51,22,15)(16,45,36)(18,27,35,48,52,54)(24,63,42)(30,39,60)
+           (1,2,6,19,35,33)(3,9,26,14,31,23)(4,13,5)(7,22,17)(8,24,12)(10,16,32,27,20,28)(11,30,18)(15,25,36,34,29,21)
            sage: PG(p._gap_()) == p
            True
 
@@ -973,12 +973,12 @@ class PermutationGroup_generic(FiniteGroup):
             sage: P = G.as_permutation_group(algorithm='smaller', seed=5)
             sage: P1 = G.as_permutation_group()
             sage: P == P1
-            False
+            True
             sage: g1, g2, g3 = G.gens()
             sage: P(g1*g2)
-            (1,3,7,12)(2,4,8,10)(5,11)(6,9)
+            (1,4,13,11)(2,5,14,18)(3,15,8,16)(6,7)(9,20,19,12)(10,17)
             sage: P1(g1*g2)
-            (2,29,25,68)(3,57,13,54)(4,11,72,37)(5,39,60,23)(6,64,75,63)(7,21,50,73)(8,46,38,32)(9,74,35,18)(10,44,49,48)(12,16,34,71)(14,79,27,40)(15,26)(17,62,59,76)(19,78,70,65)(20,22,58,51)(24,33,36,43)(28,81,80,52)(30,53,56,69)(31,61)(41,42,67,55)(45,77)(47,66)
+            (1,4,13,11)(2,5,14,18)(3,15,8,16)(6,7)(9,20,19,12)(10,17)
 
         Another check for :trac:`5583`::
 
@@ -1303,7 +1303,7 @@ class PermutationGroup_generic(FiniteGroup):
             sage: G.gens_small() # random
             [('b','c'), ('a','c','b')] ## (on 64-bit Linux)
             [('a','b'), ('a','c','b')] ## (on Solaris)
-            sage: len(G.gens_small()) == 2
+            sage: len(G.gens_small()) == 2 # random
             True
         """
         gens = self._libgap_().SmallGeneratingSet()
@@ -4371,17 +4371,23 @@ class PermutationGroup_generic(FiniteGroup):
 
         ::
 
-            sage: G = PermutationGroup([[(1,2,3,4,5)],[(1,2)]]) #S_5 on [1..5]
-            sage: G.is_transitive([1,4,5])
+            sage: G = PermutationGroup([[(1,2,3,4,5)],[(1,2)],[(6,7)]])
+            sage: G.is_transitive([1,2,3,4,5])
             True
-            sage: G.is_transitive([2..6])
+            sage: G.is_transitive([1..7])
             False
             sage: G.is_transitive(G.non_fixed_points())
-            True
+            False
             sage: H = PermutationGroup([[(1,2,3)],[(4,5,6)]])
             sage: H.is_transitive(H.non_fixed_points())
             False
 
+        If `G` does not act on the domain, it always returns ``False``::
+
+            sage: G = PermutationGroup([[(1,2,3,4,5)],[(1,2)]]) #S_5 on [1..5]
+            sage: G.is_transitive([1,4,5])
+            False
+
         Note that this differs from the definition in GAP, where
         ``IsTransitive`` returns whether the group is transitive on the
         set of points moved by the group.
@@ -4437,12 +4443,16 @@ class PermutationGroup_generic(FiniteGroup):
             sage: G = PermutationGroup([[(1,2,3,4)],[(2,4)]])
             sage: G.is_primitive([1..4])
             False
-            sage: G.is_primitive([1,2,3])
-            True
             sage: G = PermutationGroup([[(3,4,5,6)],[(3,4)]]) #S_4 on [3..6]
             sage: G.is_primitive(G.non_fixed_points())
             True
 
+        If `G` does not act on the domain, it always returns ``False``::
+
+            sage: G = PermutationGroup([[(1,2,3,4)],[(2,4)]])
+            sage: G.is_primitive([1,2,3])
+            False
+
         """
         #If the domain is not a subset of self.domain(), then the
         #action isn't primitive.
diff --git a/src/sage/interfaces/gap.py b/src/sage/interfaces/gap.py
index ba175d4e34..d866cd3d60 100644
--- a/src/sage/interfaces/gap.py
+++ b/src/sage/interfaces/gap.py
@@ -1512,6 +1512,8 @@ def gap_reset_workspace(max_workspace_size=None, verbose=False):
     """
     # Create new workspace with filename WORKSPACE
     g = Gap(use_workspace_cache=False, max_workspace_size=None)
+    g.eval('ColorPrompt(false)')
+    g.eval('SetUserPreference("UseColorPrompt", false)')
     g.eval('SetUserPreference("HistoryMaxLines", 30)')
     from sage.tests.gap_packages import all_installed_packages
     for pkg in all_installed_packages(gap=g):
diff --git a/src/sage/libs/gap/element.pyx b/src/sage/libs/gap/element.pyx
index be43c4c3ee..e2681165a2 100644
--- a/src/sage/libs/gap/element.pyx
+++ b/src/sage/libs/gap/element.pyx
@@ -130,6 +130,7 @@ cdef char *capture_stdout(Obj func, Obj obj):
     """
     cdef Obj s, stream, output_text_string
     cdef UInt res
+    cdef TypOutputFile output
     # The only way to get a string representation of an object that is truly
     # consistent with how it would be represented at the GAP REPL is to call
     # ViewObj on it.  Unfortunately, ViewObj *prints* to the output stream,
@@ -145,12 +146,12 @@ cdef char *capture_stdout(Obj func, Obj obj):
         output_text_string = GAP_ValueGlobalVariable("OutputTextString")
         stream = CALL_2ARGS(output_text_string, s, GAP_True)
 
-        if not OpenOutputStream(stream):
+        if not OpenOutputStream(&output, stream):
             raise GAPError("failed to open output capture stream for "
                            "representing GAP object")
 
         CALL_1ARGS(func, obj)
-        CloseOutput()
+        CloseOutput(&output)
         return CSTR_STRING(s)
     finally:
         GAP_Leave()
diff --git a/src/sage/libs/gap/gap_includes.pxd b/src/sage/libs/gap/gap_includes.pxd
index 5a9ab486f7..34035fe4e6 100644
--- a/src/sage/libs/gap/gap_includes.pxd
+++ b/src/sage/libs/gap/gap_includes.pxd
@@ -76,8 +76,10 @@ cdef extern from "gap/intobj.h" nogil:
 
 
 cdef extern from "gap/io.h" nogil:
-    UInt OpenOutputStream(Obj stream)
-    UInt CloseOutput()
+    ctypedef struct TypOutputFile:
+        pass
+    UInt OpenOutputStream(TypOutputFile* output, Obj stream)
+    UInt CloseOutput(TypOutputFile* output)
 
 
 cdef extern from "gap/libgap-api.h" nogil:
diff --git a/src/sage/libs/gap/libgap.pyx b/src/sage/libs/gap/libgap.pyx
index b1a64e5793..6a36613aa8 100644
--- a/src/sage/libs/gap/libgap.pyx
+++ b/src/sage/libs/gap/libgap.pyx
@@ -695,7 +695,7 @@ class Gap(Parent):
             sage: libgap.List
             <Gap function "List">
             sage: libgap.GlobalRandomSource
-            <RandomSource in IsGlobalRandomSource>
+            <RandomSource in IsGAPRandomSource>
         """
         if name in dir(self.__class__):
             return getattr(self.__class__, name)
diff --git a/src/sage/libs/gap/util.pyx b/src/sage/libs/gap/util.pyx
index 344ab88c42..635098767d 100644
--- a/src/sage/libs/gap/util.pyx
+++ b/src/sage/libs/gap/util.pyx
@@ -362,15 +362,9 @@ cdef Obj gap_eval(str gap_string) except? NULL:
         GAPError: Error, Variable: 'Complex' must have a value
         Syntax error: ; expected in stream:1
         Complex Field with 53 bits of precision;;
-         ^^^^^^^^^^^^
+                ^^^^^
         Error, Variable: 'with' must have a value
-        Syntax error: ; expected in stream:1
-        Complex Field with 53 bits of precision;;
-         ^^^^^^^^^^^^^^^^^^^^
         Error, Variable: 'bits' must have a value
-        Syntax error: ; expected in stream:1
-        Complex Field with 53 bits of precision;;
-         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         Error, Variable: 'precision' must have a value
 
     Test that on a subsequent attempt we get the same message (no garbage was
diff --git a/src/sage/tests/gap_packages.py b/src/sage/tests/gap_packages.py
index 2e4518ca22..c302b169b8 100644
--- a/src/sage/tests/gap_packages.py
+++ b/src/sage/tests/gap_packages.py
@@ -103,7 +103,7 @@ def all_installed_packages(ignore_dot_gap=False, gap=None):
 
         sage: from sage.tests.gap_packages import all_installed_packages
         sage: all_installed_packages()
-        (...'GAPDoc'...)
+        (...'gapdoc'...)
         sage: all_installed_packages(ignore_dot_gap=True) == all_installed_packages(gap=gap, ignore_dot_gap=True)
         True
     """

A sagemath-git/sagemath-ipywidgets-8.patch => sagemath-git/sagemath-ipywidgets-8.patch +489 -0
@@ 0,0 1,489 @@
diff --git a/src/sage/combinat/cluster_algebra_quiver/cluster_seed.py b/src/sage/combinat/cluster_algebra_quiver/cluster_seed.py
index e65d605..d7c4d84 100644
--- a/src/sage/combinat/cluster_algebra_quiver/cluster_seed.py
+++ b/src/sage/combinat/cluster_algebra_quiver/cluster_seed.py
@@ -1062,7 +1062,7 @@ class ClusterSeed(SageObject):
 
             sage: S = ClusterSeed(['A',4])
             sage: S.interact()
-            VBox(children=...
+            ...VBox(children=...
         """
         return cluster_interact(self, fig_size, circular, kind='seed')
 
diff --git a/src/sage/combinat/cluster_algebra_quiver/interact.py b/src/sage/combinat/cluster_algebra_quiver/interact.py
index 4e54c64..1c88e61 100644
--- a/src/sage/combinat/cluster_algebra_quiver/interact.py
+++ b/src/sage/combinat/cluster_algebra_quiver/interact.py
@@ -27,7 +27,7 @@ def cluster_interact(self, fig_size=1, circular=True, kind='seed'):
 
         sage: S = ClusterSeed(['A',4])
         sage: S.interact()   # indirect doctest
-        VBox(children=...
+        ...VBox(children=...
     """
     if kind not in ['seed', 'quiver']:
         raise ValueError('kind must be "seed" or "quiver"')
@@ -107,7 +107,7 @@ def cluster_interact(self, fig_size=1, circular=True, kind='seed'):
     show_lastmutation.observe(refresh, 'value')
     which_plot.observe(refresh, 'value')
 
-    mut_buttons.on_displayed(refresh)
+    mut_buttons.on_widget_constructed(refresh)
 
     if kind == 'seed':
         top = widgets.HBox([show_seq, show_vars])
diff --git a/src/sage/combinat/cluster_algebra_quiver/quiver.py b/src/sage/combinat/cluster_algebra_quiver/quiver.py
index 4f6e16b..14a176c 100644
--- a/src/sage/combinat/cluster_algebra_quiver/quiver.py
+++ b/src/sage/combinat/cluster_algebra_quiver/quiver.py
@@ -699,7 +699,7 @@ class ClusterQuiver(SageObject):
 
             sage: S = ClusterQuiver(['A',4])
             sage: S.interact()
-            VBox(children=...
+            ...VBox(children=...
         """
         return cluster_interact(self, fig_size, circular, kind="quiver")
 
diff --git a/src/sage/dynamics/complex_dynamics/mandel_julia.py b/src/sage/dynamics/complex_dynamics/mandel_julia.py
index 224a484..ce67274 100644
--- a/src/sage/dynamics/complex_dynamics/mandel_julia.py
+++ b/src/sage/dynamics/complex_dynamics/mandel_julia.py
@@ -130,7 +130,7 @@ def mandelbrot_plot(f=None, **kwds):
     ``interact`` to ``True``. (This is only implemented for ``z^2 + c``)::
 
         sage: mandelbrot_plot(interact=True)
-        interactive(children=(FloatSlider(value=0.0, description='Real center', max=1.0, min=-1.0, step=1e-05),
+        ...interactive(children=(FloatSlider(value=0.0, description='Real center', max=1.0, min=-1.0, step=1e-05),
         FloatSlider(value=0.0, description='Imag center', max=1.0, min=-1.0, step=1e-05),
         FloatSlider(value=4.0, description='Width', max=4.0, min=1e-05, step=1e-05),
         IntSlider(value=500, description='Iterations', max=1000),
@@ -144,7 +144,7 @@ def mandelbrot_plot(f=None, **kwds):
 
         sage: mandelbrot_plot(interact=True, x_center=-0.75, y_center=0.25,
         ....: image_width=1/2, number_of_colors=75)
-        interactive(children=(FloatSlider(value=-0.75, description='Real center', max=1.0, min=-1.0, step=1e-05),
+        ...interactive(children=(FloatSlider(value=-0.75, description='Real center', max=1.0, min=-1.0, step=1e-05),
         FloatSlider(value=0.25, description='Imag center', max=1.0, min=-1.0, step=1e-05),
         FloatSlider(value=0.5, description='Width', max=4.0, min=1e-05, step=1e-05),
         IntSlider(value=500, description='Iterations', max=1000),
@@ -600,14 +600,14 @@ def julia_plot(f=None, **kwds):
     the form ``f = z^2 + c``)::
 
         sage: julia_plot(interact=True)
-        interactive(children=(FloatSlider(value=-1.0, description='Real c'...
+        ...interactive(children=(FloatSlider(value=-1.0, description='Real c'...
 
         ::
 
         sage: R.<z> = CC[]
         sage: f = z^2 + 1/2
         sage: julia_plot(f,interact=True)
-        interactive(children=(FloatSlider(value=0.5, description='Real c'...
+        ...interactive(children=(FloatSlider(value=0.5, description='Real c'...
 
     To return the Julia set of a random `c` value with (formal) cycle structure
     `(2,3)`, set ``period = [2,3]``::
diff --git a/src/sage/interacts/library.py b/src/sage/interacts/library.py
index 8166014..6a982db 100644
--- a/src/sage/interacts/library.py
+++ b/src/sage/interacts/library.py
@@ -12,7 +12,7 @@ interactive mathlet.  In the command line, it will simply return the underlying
 HTML and Sage code which creates the mathlet::
 
     sage: interacts.calculus.taylor_polynomial()
-    Interactive function <function taylor_polynomial at ...> with 3 widgets
+    ...Interactive function <function taylor_polynomial at ...> with 3 widgets
       title: HTMLText(value='<h2>Taylor polynomial</h2>')
       f: EvalText(value='e^(-x)*sin(x)', description='$f(x)=$', layout=Layout(max_width='81em'))
       order: SelectionSlider(description='order', options=(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12), value=1)
@@ -101,7 +101,7 @@ def library_interact(
         ....: def f(n):
         ....:     print(n)
         sage: f()  # an interact appears if using the notebook, else code
-        Interactive function <function f at ...> with 1 widget
+        ...Interactive function <function f at ...> with 1 widget
         n: TransformIntSlider(value=5, description='n', max=15, min=-5)
 
     TESTS:
@@ -117,7 +117,7 @@ def library_interact(
         DeprecationWarning: Use decorator factory @library_interact(widgets) instead of @library_interact without any arguments.
         See https://trac.sagemath.org/33382 for details.
         sage: f()  # an interact appears if using the notebook, else code
-        Interactive function <function f at ...> with 1 widget
+        ...Interactive function <function f at ...> with 1 widget
         n: TransformIntSlider(value=5, description='n', max=15, min=-5)
 
     .. NOTE::
@@ -183,7 +183,7 @@ def demo(n: int, m: int):
     creates the mathlet::
 
         sage: interacts.demo()
-        Interactive function <function demo at ...> with 2 widgets
+        ...Interactive function <function demo at ...> with 2 widgets
           n: SelectionSlider(description='n', options=(0, 1, 2, 3, 4, 5, 6, 7, 8, 9), value=0)
           m: SelectionSlider(description='m', options=(0, 1, 2, 3, 4, 5, 6, 7, 8, 9), value=0)
     """
@@ -213,7 +213,7 @@ def taylor_polynomial(title, f, order: int):
     creates the mathlet::
 
         sage: interacts.calculus.taylor_polynomial()
-        Interactive function <function taylor_polynomial at ...> with 3 widgets
+        ...Interactive function <function taylor_polynomial at ...> with 3 widgets
           title: HTMLText(value='<h2>Taylor polynomial</h2>')
           f: EvalText(value='e^(-x)*sin(x)', description='$f(x)=$', layout=Layout(max_width='81em'))
           order: SelectionSlider(description='order', options=(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12), value=1)
@@ -259,7 +259,7 @@ def definite_integral(title, f, g, interval, x_range, selection):
     creates the mathlet::
 
         sage: interacts.calculus.definite_integral()
-        Interactive function <function definite_integral at ...> with 6 widgets
+        ...Interactive function <function definite_integral at ...> with 6 widgets
           title: HTMLText(value='<h2>Definite integral</h2>')
           f: EvalText(value='3*x', description='$f(x)=$', layout=Layout(max_width='81em'))
           g: EvalText(value='x^2', description='$g(x)=$', layout=Layout(max_width='81em'))
@@ -345,7 +345,7 @@ def function_derivative(title, function, x_range, y_range):
     creates the mathlet::
 
         sage: interacts.calculus.function_derivative()
-        Interactive function <function function_derivative at ...> with 4 widgets
+        ...Interactive function <function function_derivative at ...> with 4 widgets
           title: HTMLText(value='<h2>Derivative grapher</h2>')
           function: EvalText(value='x^5-3*x^3+1', description='Function:', layout=Layout(max_width='81em'))
           x_range: FloatRangeSlider(value=(-2.0, 2.0), description='Range (x)', max=15.0, min=-15.0)
@@ -393,7 +393,7 @@ def difference_quotient(title, f, interval, a, x0):
     creates the mathlet::
 
         sage: interacts.calculus.difference_quotient()
-        Interactive function <function difference_quotient at ...> with 5 widgets
+        ...Interactive function <function difference_quotient at ...> with 5 widgets
           title: HTMLText(value='<h2>Difference quotient</h2>')
           f: EvalText(value='sin(x)', description='f(x)', layout=Layout(max_width='81em'))
           interval: FloatRangeSlider(value=(0.0, 10.0), description='Range', max=10.0)
@@ -458,7 +458,7 @@ def quadratic_equation(A, B, C):
     creates the mathlet::
 
         sage: interacts.calculus.quadratic_equation()
-        Interactive function <function quadratic_equation at ...> with 3 widgets
+        ...Interactive function <function quadratic_equation at ...> with 3 widgets
           A: IntSlider(value=1, description='A', max=7, min=-7)
           B: IntSlider(value=1, description='B', max=7, min=-7)
           C: IntSlider(value=-2, description='C', max=7, min=-7)
@@ -520,7 +520,7 @@ def trigonometric_properties_triangle(a0, a1, a2):
     creates the mathlet::
 
         sage: interacts.geometry.trigonometric_properties_triangle()
-        Interactive function <function trigonometric_properties_triangle at ...> with 3 widgets
+        ...Interactive function <function trigonometric_properties_triangle at ...> with 3 widgets
           a0: IntSlider(value=30, description='A', max=360)
           a1: IntSlider(value=180, description='B', max=360)
           a2: IntSlider(value=300, description='C', max=360)
@@ -601,7 +601,7 @@ def unit_circle(function, x):
     creates the mathlet::
 
         sage: interacts.geometry.unit_circle()
-        Interactive function <function unit_circle at ...> with 2 widgets
+        ...Interactive function <function unit_circle at ...> with 2 widgets
           function: Dropdown(description='function', options=(('sin(x)', 0), ('cos(x)', 1), ('tan(x)', 2)), value=0)
           x: TransformFloatSlider(value=0.0, description='x', max=6.283185307179586, step=0.015707963267948967)
     """
@@ -702,7 +702,7 @@ def special_points(
     creates the mathlet::
 
         sage: interacts.geometry.special_points()
-        Interactive function <function special_points at ...> with 10 widgets
+        ...Interactive function <function special_points at ...> with 10 widgets
           title: HTMLText(value='<h2>Special points in triangle</h2>')
           a0: IntSlider(value=30, description='A', max=360)
           a1: IntSlider(value=180, description='B', max=360)
@@ -875,7 +875,7 @@ def coin(n, interval):
     creates the mathlet::
 
         sage: interacts.statistics.coin()
-        Interactive function <function coin at ...> with 2 widgets
+        ...Interactive function <function coin at ...> with 2 widgets
           n: IntSlider(value=1000, description='Number of Tosses', max=10000, min=2, step=100)
           interval: IntRangeSlider(value=(0, 0), description='Plotting range (y)', max=1)
     """
@@ -915,7 +915,7 @@ def bisection_method(title, f, interval, d, maxn):
     creates the mathlet::
 
         sage: interacts.calculus.secant_method()
-        Interactive function <function secant_method at ...> with 5 widgets
+        ...Interactive function <function secant_method at ...> with 5 widgets
           title: HTMLText(value='<h2>Secant method for numerical root finding</h2>')
           f: EvalText(value='x^2-2', description='f(x)', layout=Layout(max_width='81em'))
           interval: IntRangeSlider(value=(0, 4), description='range', max=5, min=-5)
@@ -995,7 +995,7 @@ def secant_method(title, f, interval, d, maxn):
     creates the mathlet::
 
         sage: interacts.calculus.secant_method()
-        Interactive function <function secant_method at ...> with 5 widgets
+        ...Interactive function <function secant_method at ...> with 5 widgets
           title: HTMLText(value='<h2>Secant method for numerical root finding</h2>')
           f: EvalText(value='x^2-2', description='f(x)', layout=Layout(max_width='81em'))
           interval: IntRangeSlider(value=(0, 4), description='range', max=5, min=-5)
@@ -1068,7 +1068,7 @@ def newton_method(title, f, c, d, maxn, interval, list_steps):
     creates the mathlet::
 
         sage: interacts.calculus.newton_method()
-        Interactive function <function newton_method at ...> with 7 widgets
+        ...Interactive function <function newton_method at ...> with 7 widgets
           title: HTMLText(value='<h2>Newton method</h2>')
           f: EvalText(value='x^2 - 2', description='f', layout=Layout(max_width='81em'))
           c: IntSlider(value=6, description='Start ($x$)', max=10, min=-10)
@@ -1152,7 +1152,7 @@ def trapezoid_integration(
     creates the mathlet::
 
         sage: interacts.calculus.trapezoid_integration()
-        Interactive function <function trapezoid_integration at ...> with 7 widgets
+        ...Interactive function <function trapezoid_integration at ...> with 7 widgets
           title: HTMLText(value='<h2>Trapezoid integration</h2>')
           f: EvalText(value='x^2-5*x + 10', description='$f(x)=$', layout=Layout(max_width='81em'))
           n: IntSlider(value=5, description='# divisions', min=1)
@@ -1284,7 +1284,7 @@ def simpson_integration(
     creates the mathlet::
 
         sage: interacts.calculus.simpson_integration()
-        Interactive function <function simpson_integration at ...> with 7 widgets
+        ...Interactive function <function simpson_integration at ...> with 7 widgets
           title: HTMLText(value='<h2>Simpson integration</h2>')
           f: EvalText(value='x*sin(x)+x+1', description='$f(x)=$', layout=Layout(max_width='81em'))
           n: IntSlider(value=6, description='# divisions', min=2, step=2)
@@ -1547,7 +1547,7 @@ def function_tool(f, g, xrange, yrange, a, action, do_plot):
     creates the mathlet::
 
         sage: interacts.calculus.function_tool()
-        Interactive function <function function_tool at ...> with 7 widgets
+        ...Interactive function <function function_tool at ...> with 7 widgets
           f: EvalText(value='sin(x)', description='f')
           g: EvalText(value='cos(x)', description='g')
           xrange: IntRangeSlider(value=(0, 1), description='x-range', max=3, min=-3)
@@ -1677,7 +1677,7 @@ def julia(expo, c_real, c_imag, iterations, zoom_x, zoom_y, plot_points, dpi):
     creates the mathlet::
 
         sage: interacts.fractals.julia()
-        Interactive function <function julia at ...> with 8 widgets
+        ...Interactive function <function julia at ...> with 8 widgets
           expo: FloatSlider(value=2.0, description='expo', max=10.0, min=-10.0)
           c_real: FloatSlider(value=0.5, description='real part const.', max=2.0, min=-2.0, step=0.01)
           c_imag: FloatSlider(value=0.5, description='imag part const.', max=2.0, min=-2.0, step=0.01)
@@ -1729,7 +1729,7 @@ def mandelbrot(expo, iterations, zoom_x, zoom_y, plot_points, dpi):
     creates the mathlet::
 
         sage: interacts.fractals.mandelbrot()
-        Interactive function <function mandelbrot at ...> with 6 widgets
+        ...Interactive function <function mandelbrot at ...> with 6 widgets
           expo: FloatSlider(value=2.0, description='expo', max=10.0, min=-10.0)
           iterations: IntSlider(value=20, description='# iterations', min=1)
           zoom_x: FloatRangeSlider(value=(-2.0, 1.0), description='Zoom X', max=2.0, min=-2.0, step=0.01)
@@ -1774,7 +1774,7 @@ def cellular_automaton(N, rule_number, size):
     creates the mathlet::
 
         sage: interacts.fractals.cellular_automaton()
-        Interactive function <function cellular_automaton at ...> with 3 widgets
+        ...Interactive function <function cellular_automaton at ...> with 3 widgets
           N: IntSlider(value=100, description='Number of iterations', max=500, min=1)
           rule_number: IntSlider(value=110, description='Rule number', max=255)
           size: IntSlider(value=6, description='size of graphic', max=11, min=1)
@@ -1833,7 +1833,7 @@ def polar_prime_spiral(interval, show_factors, highlight_primes, show_curves, n,
     creates the mathlet::
 
         sage: sage.interacts.algebra.polar_prime_spiral()
-        Interactive function <function polar_prime_spiral at ...> with 6 widgets
+        ...Interactive function <function polar_prime_spiral at ...> with 6 widgets
           interval: IntRangeSlider(value=(1, 1000), description='range', max=4000, min=1, step=10)
           show_factors: Checkbox(value=True, description='show_factors')
           highlight_primes: Checkbox(value=True, description='highlight_primes')
diff --git a/src/sage/plot/plot3d/plot3d.py b/src/sage/plot/plot3d/plot3d.py
index 44620a0..43e1ce9 100644
--- a/src/sage/plot/plot3d/plot3d.py
+++ b/src/sage/plot/plot3d/plot3d.py
@@ -1300,7 +1300,7 @@ def plot3d(f, urange, vrange, adaptive=False, transformation=None, **kwds):
         sage: @interact
         ....: def _(which_plot=[A,B,C,D,E]):
         ....:     show(which_plot)
-        Interactive function <function _ at ...> with 1 widget
+        ...Interactive function <function _ at ...> with 1 widget
           which_plot: Dropdown(description='which_plot', options=(Graphics3d Object, Graphics3d Object, Graphics3d Object, Graphics3d Object, Graphics3d Object), value=Graphics3d Object)
 
     Now plot a function::
@@ -1314,7 +1314,7 @@ def plot3d(f, urange, vrange, adaptive=False, transformation=None, **kwds):
         sage: @interact
         ....: def _(which_plot=[F, G, H, I, J]):
         ....:     show(which_plot)
-        Interactive function <function _ at ...> with 1 widget
+        ...Interactive function <function _ at ...> with 1 widget
           which_plot: Dropdown(description='which_plot', options=(Graphics3d Object, Graphics3d Object, Graphics3d Object, Graphics3d Object, Graphics3d Object), value=Graphics3d Object)
 
     TESTS:
diff --git a/src/sage/repl/display/formatter.py b/src/sage/repl/display/formatter.py
index adde08d..62bde3b 100644
--- a/src/sage/repl/display/formatter.py
+++ b/src/sage/repl/display/formatter.py
@@ -169,8 +169,7 @@ class SageDisplayFormatter(DisplayFormatter):
             sage: shell.run_cell('import ipywidgets')
             sage: shell.run_cell('slider = ipywidgets.IntSlider()')
             sage: shell.run_cell('get_ipython().display_formatter.format(slider)')
-            IntSlider(value=0)
-            ({}, {})
+            ...IntSlider(value=0)..., {})
 
             sage: shell.run_cell('%display default')
             sage: shell.quit()
diff --git a/src/sage/repl/ipython_kernel/interact.py b/src/sage/repl/ipython_kernel/interact.py
index 9b94bc4..a2665a4 100644
--- a/src/sage/repl/ipython_kernel/interact.py
+++ b/src/sage/repl/ipython_kernel/interact.py
@@ -18,7 +18,7 @@ EXAMPLES::
     sage: @interact
     ....: def f(x=(0, 10)):
     ....:     pass
-    Interactive function <function f at ...> with 1 widget
+    ...Interactive function <function f at ...> with 1 widget
       x: IntSlider(value=5, description='x', max=10)
     sage: f.widget.children
     (IntSlider(value=5, description='x', max=10), Output())
@@ -69,7 +69,7 @@ class sage_interactive(interactive):
         sage: from sage.repl.ipython_kernel.interact import sage_interactive
         sage: def myfunc(x=10, y="hello", z=None): pass
         sage: sage_interactive(myfunc, x=(0,100), z=["one", "two", "three"])
-        Interactive function <function myfunc at ...> with 3 widgets
+        ...Interactive function <function myfunc at ...> with 3 widgets
           x: IntSlider(value=10, description='x')
           y: Text(value='hello', description='y')
           z: Dropdown(description='z', options=('one', 'two', 'three'), value=None)
@@ -99,10 +99,10 @@ class sage_interactive(interactive):
 
             sage: def myfunc(auto_update=False): pass
             sage: sage_interactive(myfunc)
-            Manual interactive function <function myfunc ...> with 0 widgets
+            ...Manual interactive function <function myfunc ...> with 0 widgets
             sage: def myfunc(auto_update=None): pass
             sage: sage_interactive(myfunc)
-            Interactive function <function myfunc ...> with 0 widgets
+            ...Interactive function <function myfunc ...> with 0 widgets
         """
         # Use *args to avoid name clash with keyword arguments
         if len(args) < 2:
@@ -126,7 +126,7 @@ class sage_interactive(interactive):
         super(sage_interactive, self).__init__(f, options, **kwds)
         if self.manual:
             # In Sage, manual interacts are always run once
-            self.on_displayed(self.update)
+            self.on_widget_constructed(self.update)
         else:
             # In automatic mode, clicking on a ToggleButtons button
             # should also run the interact
@@ -143,7 +143,7 @@ class sage_interactive(interactive):
             sage: from sage.repl.ipython_kernel.interact import sage_interactive
             sage: def myfunc(): pass
             sage: sage_interactive(myfunc)
-            Interactive function <function myfunc ...> with 0 widgets
+            ...Interactive function <function myfunc ...> with 0 widgets
         """
         s = "Manual interactive" if self.manual else "Interactive"
         widgets = [w for w in self.children if isinstance(w, ValueWidget)]
@@ -164,7 +164,7 @@ class sage_interactive(interactive):
             sage: from sage.repl.ipython_kernel.interact import sage_interactive
             sage: def myfunc(x=[1,2,3], auto_update=False): pass
             sage: sage_interactive(myfunc).signature().parameters
-            mappingproxy({'x': <Parameter "x=[1, 2, 3]">})
+            ...mappingproxy({'x': <Parameter "x=[1, 2, 3]">})
         """
         return self.__signature
 
@@ -181,14 +181,14 @@ class sage_interactive(interactive):
 
             sage: from sage.repl.ipython_kernel.interact import sage_interactive
             sage: sage_interactive.widget_from_single_value("sin(x)")
-            Text(value='sin(x)')
+            ...Text(value='sin(x)')
             sage: sage_interactive.widget_from_single_value(sin(x))
-            EvalText(value='sin(x)')
+            ...EvalText(value='sin(x)')
             sage: from sage.plot.colors import Color
             sage: sage_interactive.widget_from_single_value(matrix([[1, 2], [3, 4]]))
-            Grid(value=[[1, 2], [3, 4]], children=(Label(value=''), VBox(children=(EvalText(value='1', layout=Layout(max_width='5em')), EvalText(value='3', layout=Layout(max_width='5em')))), VBox(children=(EvalText(value='2', layout=Layout(max_width='5em')), EvalText(value='4', layout=Layout(max_width='5em'))))))
+            ...Grid(value=[[1, 2], [3, 4]], children=(Label(value=''), VBox(children=(EvalText(value='1', layout=Layout(max_width='5em')), EvalText(value='3', layout=Layout(max_width='5em')))), VBox(children=(EvalText(value='2', layout=Layout(max_width='5em')), EvalText(value='4', layout=Layout(max_width='5em'))))))
             sage: sage_interactive.widget_from_single_value(Color('cornflowerblue'))
-            SageColorPicker(value='#6495ed')
+            ...SageColorPicker(value='#6495ed')
         """
         # Support Sage matrices and colors
         if isinstance(abbrev, Matrix):
@@ -219,15 +219,15 @@ class sage_interactive(interactive):
 
             sage: from sage.repl.ipython_kernel.interact import sage_interactive
             sage: sage_interactive.widget_from_tuple( (0, 10) )
-            IntSlider(value=5, max=10)
+            ...IntSlider(value=5, max=10)
             sage: sage_interactive.widget_from_tuple( ("number", (0, 10)) )
-            IntSlider(value=5, description='number', max=10)
+            ...IntSlider(value=5, description='number', max=10)
             sage: sage_interactive.widget_from_tuple( (3, (0, 10)) )
-            IntSlider(value=3, max=10)
-            sage: sage_interactive.widget_from_tuple((2, dict(one=1, two=2, three=3)))
-            Dropdown(index=1, options={'one': 1, 'two': 2, 'three': 3}, value=2)
+            ...IntSlider(value=3, max=10)
+            sage: sage_interactive.widget_from_tuple((2, [('one', 1), ('two', 2), ('three', 3)]))
+            ...Dropdown(index=1, options=(('one', 1), ('two', 2), ('three', 3)), value=2)
             sage: sage_interactive.widget_from_tuple( (sqrt(2), pi) )
-            FloatSlider(value=2.277903107981444, max=3.141592653589793, min=1.4142135623730951)
+            ...FloatSlider(value=2.277903107981444, max=3.141592653589793, min=1.4142135623730951)
 
         TESTS:
 
@@ -235,7 +235,7 @@ class sage_interactive(interactive):
 
             sage: SCR = SR.subring(no_variables=True)
             sage: sage_interactive.widget_from_tuple( (SCR(sqrt(2)), SCR(pi)) )
-            FloatSlider(value=2.277903107981444, max=3.141592653589793, min=1.4142135623730951)
+            ...FloatSlider(value=2.277903107981444, max=3.141592653589793, min=1.4142135623730951)
         """
         # Support (description, abbrev)
         if len(abbrev) == 2 and isinstance(abbrev[0], str):
@@ -269,17 +269,17 @@ class sage_interactive(interactive):
 
             sage: from sage.repl.ipython_kernel.interact import sage_interactive
             sage: sage_interactive.widget_from_iterable([1..5])
-            Dropdown(options=(1, 2, 3, 4, 5), value=1)
+            ...Dropdown(options=(1, 2, 3, 4, 5), value=1)
             sage: sage_interactive.widget_from_iterable(iter([1..5]))
-            SelectionSlider(options=(1, 2, 3, 4, 5), value=1)
+            ...SelectionSlider(options=(1, 2, 3, 4, 5), value=1)
             sage: sage_interactive.widget_from_iterable((1..5))
-            SelectionSlider(options=(1, 2, 3, 4, 5), value=1)
+            ...SelectionSlider(options=(1, 2, 3, 4, 5), value=1)
             sage: sage_interactive.widget_from_iterable(x for x in [1..5])
-            SelectionSlider(options=(1, 2, 3, 4, 5), value=1)
+            ...SelectionSlider(options=(1, 2, 3, 4, 5), value=1)
             sage: def gen():
             ....:     yield 1; yield 2; yield 3; yield 4; yield 5
             sage: sage_interactive.widget_from_iterable(gen())
-            SelectionSlider(options=(1, 2, 3, 4, 5), value=1)
+            ...SelectionSlider(options=(1, 2, 3, 4, 5), value=1)
         """
         if isinstance(abbrev, Iterator):
             return SelectionSlider(options=list(abbrev))
diff --git a/src/sage/repl/ipython_kernel/widgets_sagenb.py b/src/sage/repl/ipython_kernel/widgets_sagenb.py
index 2ce59d7..76f4f52 100644
--- a/src/sage/repl/ipython_kernel/widgets_sagenb.py
+++ b/src/sage/repl/ipython_kernel/widgets_sagenb.py
@@ -470,15 +470,6 @@ def selector(values, label=None, default=None, nrows=None, ncols=None, width=Non
         sage: selector([(1,"one"), (2,"two"), (3,"three")], buttons=True)
         ToggleButtons(options=(('one', 1), ('two', 2), ('three', 3)), value=1)
 
-    A dict of ``label:value`` pairs is also allowed. Since a ``dict``
-    is not ordered, it is better to use an :class:`OrderedDict`::
-
-        sage: from collections import OrderedDict
-        sage: selector(OrderedDict(one=1, two=2, three=3))
-        Dropdown(options=OrderedDict([('one', 1), ('two', 2), ('three', 3)]), value=1)
-        sage: selector(OrderedDict(one=1, two=2, three=3), buttons=True)
-        ToggleButtons(options=OrderedDict([('one', 1), ('two', 2), ('three', 3)]), value=1)
-
     The values can be any kind of object:
 
         sage: selector([sin(x^2), GF(29), EllipticCurve('37a1')])

A sagemath-git/sagemath-linbox-1.7.patch => sagemath-git/sagemath-linbox-1.7.patch +58 -0
@@ 0,0 1,58 @@
diff --git a/src/sage/libs/linbox/conversion.pxd b/src/sage/libs/linbox/conversion.pxd
index 7794c9e..1753277 100644
--- a/src/sage/libs/linbox/conversion.pxd
+++ b/src/sage/libs/linbox/conversion.pxd
@@ -177,9 +177,8 @@ cdef inline Vector_integer_dense new_sage_vector_integer_dense(P, DenseVector_in
     - v -- linbox vector
     """
     cdef Vector_integer_dense res = P()
-    cdef cppvector[Integer] * vec = &v.refRep()
     cdef size_t i
     for i in range(<size_t> res._degree):
-        mpz_set(res._entries[i], vec[0][i].get_mpz_const())
+        mpz_set(res._entries[i], v.getEntry(i).get_mpz_const())
 
     return res
diff --git a/src/sage/libs/linbox/linbox.pxd b/src/sage/libs/linbox/linbox.pxd
index 9112d15..dcc4829 100644
--- a/src/sage/libs/linbox/linbox.pxd
+++ b/src/sage/libs/linbox/linbox.pxd
@@ -32,7 +32,7 @@ cdef extern from "linbox/matrix/dense-matrix.h":
         ctypedef Modular_double Field
         ctypedef double Element
         DenseMatrix_Modular_double(Field F, size_t m, size_t n)
-        DenseMatrix_Modular_double(Field F, Element*, size_t m, size_t n)
+        DenseMatrix_Modular_double(Field F, size_t m, size_t n, Element*)
         void setEntry(size_t i, size_t j, Element& a)
         Element &getEntry(size_t i, size_t j)
 
@@ -42,7 +42,7 @@ cdef extern from "linbox/matrix/dense-matrix.h":
         ctypedef Modular_float Field
         ctypedef float Element
         DenseMatrix_Modular_float(Field F, size_t m, size_t n)
-        DenseMatrix_Modular_float(Field F, Element*, size_t m, size_t n)
+        DenseMatrix_Modular_float(Field F, size_t m, size_t n, Element*)
         void setEntry(size_t i, size_t j, Element& a)
         Element &getEntry(size_t i, size_t j)
 
@@ -101,7 +101,6 @@ cdef extern from "linbox/vector/vector.h":
         DenseVector_integer (Field &F)
         DenseVector_integer (Field &F, long& m)
         DenseVector_integer (Field &F, cppvector[Integer]&)
-        cppvector[Element]& refRep()
         size_t size()
         void resize(size_t)
         void resize(size_t n, const Element&)
diff --git a/src/sage/matrix/matrix_modn_dense_template.pxi b/src/sage/matrix/matrix_modn_dense_template.pxi
index 010365d..3d60726 100644
--- a/src/sage/matrix/matrix_modn_dense_template.pxi
+++ b/src/sage/matrix/matrix_modn_dense_template.pxi
@@ -219,7 +219,7 @@ cdef inline linbox_echelonize_efd(celement modulus, celement* entries, Py_ssize_
         return 0,[]
 
     cdef ModField *F = new ModField(<long>modulus)
-    cdef DenseMatrix *A = new DenseMatrix(F[0], <ModField.Element*>entries,<Py_ssize_t>nrows, <Py_ssize_t>ncols)
+    cdef DenseMatrix *A = new DenseMatrix(F[0], <Py_ssize_t>nrows, <Py_ssize_t>ncols, <ModField.Element*>entries)
     cdef Py_ssize_t r = reducedRowEchelonize(A[0])
     cdef Py_ssize_t i,j
     for i in range(nrows):

A sagemath-git/sagemath-optional-packages.patch => sagemath-git/sagemath-optional-packages.patch +17 -0
@@ 0,0 1,17 @@
diff --git a/pkgs/sagemath-standard/setup.py b/pkgs/sagemath-standard/setup.py
index 6744236593..a038006449 100755
--- a/pkgs/sagemath-standard/setup.py
+++ b/pkgs/sagemath-standard/setup.py
@@ -81,10 +81,9 @@ else:
     from sage_setup.optional_extension import is_package_installed_and_updated
     distributions = ['']
     optional_packages_with_extensions = ['mcqd', 'bliss', 'tdlib',
-                                         'coxeter3', 'fes', 'sirocco', 'meataxe']
+                                         'coxeter3', 'sirocco', 'meataxe']
     distributions += ['sagemath-{}'.format(pkg)
-                      for pkg in optional_packages_with_extensions
-                      if is_package_installed_and_updated(pkg)]
+                      for pkg in optional_packages_with_extensions]
     log.warn('distributions = {0}'.format(distributions))
     from sage_setup.find import find_python_sources
     python_packages, python_modules, cython_modules = find_python_sources(

A sagemath-git/sagemath-pari-2.15.patch => sagemath-git/sagemath-pari-2.15.patch +1737 -0
@@ 0,0 1,1737 @@
diff --git a/build/pkgs/giac/patches/pari_2_15.patch b/build/pkgs/giac/patches/pari_2_15.patch
new file mode 100644
index 0000000000..d2900a5ffc
--- /dev/null
+++ b/build/pkgs/giac/patches/pari_2_15.patch
@@ -0,0 +1,21 @@
+ANYARG patch
+
+diff --git a/src/pari.cc b/src/pari.cc
+index 76ce8e1..50d08ab 100644
+--- a/src/pari.cc
++++ b/src/pari.cc
+@@ -40,6 +40,13 @@ using namespace std;
+ 
+ #ifdef HAVE_LIBPARI
+ 
++// Anyarg disappeared from PARI 2.15.0
++#ifdef __cplusplus
++#  define ANYARG ...
++#else
++#  define ANYARG
++#endif
++
+ #ifdef HAVE_PTHREAD_H
+ #include <pthread.h>
+ #endif
+
diff --git a/build/pkgs/pari/checksums.ini b/build/pkgs/pari/checksums.ini
index b736feed31..bafd0f36f4 100644
--- a/build/pkgs/pari/checksums.ini
+++ b/build/pkgs/pari/checksums.ini
@@ -1,5 +1,5 @@
 tarball=pari-VERSION.tar.gz
-sha1=e01647aab7e96a8cb4922cf26a4f224337c6647f
-md5=922f740fcdf8630b30d63dc76b58f756
-cksum=297133525
+sha1=cba9b279f67d5efe2fbbccf3be6e9725f816cf07
+md5=76d430f1bea1b07fa2ad9712deeaa736
+cksum=1990743897
 upstream_url=https://pari.math.u-bordeaux.fr/pub/pari/unix/pari-VERSION.tar.gz
diff --git a/build/pkgs/pari/package-version.txt b/build/pkgs/pari/package-version.txt
index a1a4224dd5..68e69e405e 100644
--- a/build/pkgs/pari/package-version.txt
+++ b/build/pkgs/pari/package-version.txt
@@ -1 +1 @@
-2.13.3
+2.15.0
diff --git a/src/doc/de/tutorial/tour_numtheory.rst b/src/doc/de/tutorial/tour_numtheory.rst
index a012234c99..e3149fe949 100644
--- a/src/doc/de/tutorial/tour_numtheory.rst
+++ b/src/doc/de/tutorial/tour_numtheory.rst
@@ -157,7 +157,7 @@ implementiert.
     Univariate Quotient Polynomial Ring in a over Rational Field with modulus
     x^3 + x^2 - 2*x + 8
     sage: K.units()
-    (3*a^2 + 13*a + 13,)
+    (-3*a^2 - 13*a - 13,)
     sage: K.discriminant()
     -503
     sage: K.class_group()
diff --git a/src/doc/en/tutorial/tour_numtheory.rst b/src/doc/en/tutorial/tour_numtheory.rst
index 3064d100e2..075e0ac0ad 100644
--- a/src/doc/en/tutorial/tour_numtheory.rst
+++ b/src/doc/en/tutorial/tour_numtheory.rst
@@ -157,7 +157,7 @@ NumberField class.
     Univariate Quotient Polynomial Ring in a over Rational Field with modulus
     x^3 + x^2 - 2*x + 8
     sage: K.units()
-    (3*a^2 + 13*a + 13,)
+    (-3*a^2 - 13*a - 13,)
     sage: K.discriminant()
     -503
     sage: K.class_group()
diff --git a/src/doc/es/tutorial/tour_numtheory.rst b/src/doc/es/tutorial/tour_numtheory.rst
index a1f7d1a87b..48e5376cfe 100644
--- a/src/doc/es/tutorial/tour_numtheory.rst
+++ b/src/doc/es/tutorial/tour_numtheory.rst
@@ -140,7 +140,7 @@ Varios métodos relacionados están implementados en la clase ``NumberField``::
     Univariate Quotient Polynomial Ring in a over Rational Field with modulus
     x^3 + x^2 - 2*x + 8
     sage: K.units()
-    (3*a^2 + 13*a + 13,)
+    (-3*a^2 - 13*a - 13,)
     sage: K.discriminant()
     -503
     sage: K.class_group()
diff --git a/src/doc/fr/tutorial/tour_numtheory.rst b/src/doc/fr/tutorial/tour_numtheory.rst
index 871092f5fa..d1b2fee883 100644
--- a/src/doc/fr/tutorial/tour_numtheory.rst
+++ b/src/doc/fr/tutorial/tour_numtheory.rst
@@ -159,7 +159,7 @@ dans la classe NumberField.
     Univariate Quotient Polynomial Ring in a over Rational Field with modulus
     x^3 + x^2 - 2*x + 8
     sage: K.units()
-    (3*a^2 + 13*a + 13,)
+    (-3*a^2 - 13*a - 13,)
     sage: K.discriminant()
     -503
     sage: K.class_group()
diff --git a/src/doc/ja/tutorial/tour_numtheory.rst b/src/doc/ja/tutorial/tour_numtheory.rst
index 47af68c862..4d4ed52d50 100644
--- a/src/doc/ja/tutorial/tour_numtheory.rst
+++ b/src/doc/ja/tutorial/tour_numtheory.rst
@@ -161,7 +161,7 @@ Sageには :math:`p` \-進数体も組込まれている.
     Univariate Quotient Polynomial Ring in a over Rational Field with modulus
     x^3 + x^2 - 2*x + 8
     sage: K.units()
-    (3*a^2 + 13*a + 13,)
+    (-3*a^2 - 13*a - 13,)
     sage: K.discriminant()
     -503
     sage: K.class_group()
diff --git a/src/doc/pt/tutorial/tour_numtheory.rst b/src/doc/pt/tutorial/tour_numtheory.rst
index 6371b491ea..a3dc973a93 100644
--- a/src/doc/pt/tutorial/tour_numtheory.rst
+++ b/src/doc/pt/tutorial/tour_numtheory.rst
@@ -157,7 +157,7 @@ NumberField.
     Univariate Quotient Polynomial Ring in a over Rational Field with modulus 
     x^3 + x^2 - 2*x + 8
     sage: K.units()
-    (3*a^2 + 13*a + 13,)
+    (-3*a^2 - 13*a - 13,)
     sage: K.discriminant()
     -503
     sage: K.class_group()
diff --git a/src/doc/ru/tutorial/tour_numtheory.rst b/src/doc/ru/tutorial/tour_numtheory.rst
index 652abfbc99..a985d49fbd 100644
--- a/src/doc/ru/tutorial/tour_numtheory.rst
+++ b/src/doc/ru/tutorial/tour_numtheory.rst
@@ -150,7 +150,7 @@ Sage содержит стандартные функции теории чис
     Univariate Quotient Polynomial Ring in a over Rational Field with modulus
     x^3 + x^2 - 2*x + 8
     sage: K.units()
-    (3*a^2 + 13*a + 13,)
+    (-3*a^2 - 13*a - 13,)
     sage: K.discriminant()
     -503
     sage: K.class_group()
diff --git a/src/sage/arith/misc.py b/src/sage/arith/misc.py
index 1bd4d4c6a1..6483caa22d 100644
--- a/src/sage/arith/misc.py
+++ b/src/sage/arith/misc.py
@@ -1514,13 +1514,13 @@ def divisors(n):
 
         sage: K.<a> = QuadraticField(7)
         sage: divisors(K.ideal(7))
-        [Fractional ideal (1), Fractional ideal (-a), Fractional ideal (7)]
+        [Fractional ideal (1), Fractional ideal (a), Fractional ideal (7)]
         sage: divisors(K.ideal(3))
         [Fractional ideal (1), Fractional ideal (3),
-        Fractional ideal (-a + 2), Fractional ideal (-a - 2)]
+        Fractional ideal (a - 2), Fractional ideal (a + 2)]
         sage: divisors(K.ideal(35))
-        [Fractional ideal (1), Fractional ideal (5), Fractional ideal (-a),
-        Fractional ideal (7), Fractional ideal (-5*a), Fractional ideal (35)]
+        [Fractional ideal (1), Fractional ideal (5), Fractional ideal (a),
+        Fractional ideal (7), Fractional ideal (5*a), Fractional ideal (35)]
 
     TESTS::
 
@@ -2618,7 +2618,7 @@ def factor(n, proof=None, int_=False, algorithm='pari', verbose=0, **kwds):
 
         sage: K.<i> = QuadraticField(-1)
         sage: factor(122 - 454*i)
-        (-3*i - 2) * (-i - 2)^3 * (i + 1)^3 * (i + 4)
+        (-i) * (-i - 2)^3 * (i + 1)^3 * (-2*i + 3) * (i + 4)
 
     To access the data in a factorization::
 
diff --git a/src/sage/dynamics/arithmetic_dynamics/projective_ds.py b/src/sage/dynamics/arithmetic_dynamics/projective_ds.py
index f47d5d3624..8675935117 100644
--- a/src/sage/dynamics/arithmetic_dynamics/projective_ds.py
+++ b/src/sage/dynamics/arithmetic_dynamics/projective_ds.py
@@ -8122,9 +8122,9 @@ class DynamicalSystem_projective_field(DynamicalSystem_projective,
             sage: f = DynamicalSystem_projective([x^2 + QQbar(sqrt(3))*y^2, y^2, QQbar(sqrt(2))*z^2])
             sage: f.reduce_base_field()
             Dynamical System of Projective Space of dimension 2 over Number Field in a with
-            defining polynomial y^4 - 4*y^2 + 1 with a = 1.931851652578137?
+            defining polynomial y^4 - 4*y^2 + 1 with a = -0.5176380902050415?
               Defn: Defined on coordinates by sending (x : y : z) to
-                    (x^2 + (a^2 - 2)*y^2 : y^2 : (a^3 - 3*a)*z^2)
+                    (x^2 + (-a^2 + 2)*y^2 : y^2 : (a^3 - 3*a)*z^2)
 
         ::
 
diff --git a/src/sage/ext_data/pari/simon/ellQ.gp b/src/sage/ext_data/pari/simon/ellQ.gp
index 420af8f6a2..65e8386779 100644
--- a/src/sage/ext_data/pari/simon/ellQ.gp
+++ b/src/sage/ext_data/pari/simon/ellQ.gp
@@ -40,7 +40,7 @@
   gp > \r ellcommon.gp
   gp > \r ellQ.gp
 
-  The main function is ellrank(), which takes as an argument
+  The main function is ellQ_ellrank(), which takes as an argument
   any elliptic curve in the form [a1,a2,a3,a4,a6]
   the result is a vector [r,s,v], where
     r is a lower bound for the rank,
@@ -50,7 +50,7 @@
   Example:
 
   gp > ell = [1,2,3,4,5];
-  gp > ellrank(ell)
+  gp > ellQ_ellrank(ell)
   %1 = [1, 1, [[1,2]]
   In this example, the rank is exactly 1, and [1,2] has infinite order.
 
@@ -92,7 +92,7 @@
   \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
 
   Explications succintes :
-  La fonction ellrank() accepte toutes les courbes sous la forme
+  La fonction ellQ_ellrank() accepte toutes les courbes sous la forme
   [a1,a2,a3,a4,a6]
   Les coefficients peuvent etre entiers ou non.
   L'algorithme utilise est celui de la 2-descente.
@@ -100,7 +100,7 @@
   Il suffit de taper : 
 
   gp > ell = [a1,a2,a3,a4,a6];
-  gp > ellrank(ell)
+  gp > ellQ_ellrank(ell)
 
   Retourne un vecteur [r,s,v] ou
     r est le rang probable (c'est toujours une minoration du rang),
@@ -110,7 +110,7 @@
   Exemple :
 
   gp > ell = [1,2,3,4,5];
-  gp > ellrank(ell)
+  gp > ellQ_ellrank(ell)
   %1 = [1, 1, [[1,2]]
   Ici, le rang est exactement 1, et le point [1,2] est d'ordre infini.
 
@@ -1571,12 +1571,12 @@ if( DEBUGLEVEL_ell >= 4, print("    end of ell2descent_gen"));
     print("rank(E/Q)    >= ",m1)
   );
 }
-{ellrank(ell,help=[]) =
+{ellQ_ellrank(ell,help=[]) =
 \\ Algorithm of 2-descent on the elliptic curve ell.
 \\ help is a list of known points on ell.
 my(urst,urst1,den,eqell,tors2,bnf,rang,time1);
 
-if( DEBUGLEVEL_ell >= 3, print("   starting ellrank"));
+if( DEBUGLEVEL_ell >= 3, print("   starting ellQ_ellrank"));
   if( #ell < 13, ell = ellinit(ell));
 
 \\ kill the coefficients a1 and a3
@@ -1630,7 +1630,7 @@ if( DEBUGLEVEL_ell >= 1, print(" Elliptic curve: Y^2 = ",eqell));
   ));
 
   rang[3] = ellchangepoint(rang[3],ellinverturst(urst));
-if( DEBUGLEVEL_ell >= 3, print("   end of ellrank"));
+if( DEBUGLEVEL_ell >= 3, print("   end of ellQ_ellrank"));
 
   return(rang);
 }
@@ -2106,13 +2106,13 @@ if( DEBUGLEVEL_ell >= 3, print("   end of ell2descent_viaisog"));
 {
 \\                  functions for elliptic curves
   addhelp(ell2descent_complete,
-    "ell2descent_complete(e1,e2,e3): Performs a complete 2-descent on the elliptic curve y^2 = (x-e1)*(x-e2)*(x-e3). See ?ellrank for the format of the output.");
+    "ell2descent_complete(e1,e2,e3): Performs a complete 2-descent on the elliptic curve y^2 = (x-e1)*(x-e2)*(x-e3). See ?ellQ_ellrank for the format of the output.");
   addhelp(ell2descent_gen,
-    "ell2descent_gen((E,bnf,k=1,help=[]): E is a vector of the form [0,A,0,B,C], (or the result of ellinit of such a vector) A,B,C integers such that x^3+A*x^2+B*x+C; bnf is the corresponding bnfinit(,1); Performs 2-descent on the elliptic curve Ek: k*y^2=x^3+A*x^2+B*x+C. See ?ellrank for the format of the output.");
+    "ell2descent_gen((E,bnf,k=1,help=[]): E is a vector of the form [0,A,0,B,C], (or the result of ellinit of such a vector) A,B,C integers such that x^3+A*x^2+B*x+C; bnf is the corresponding bnfinit(,1); Performs 2-descent on the elliptic curve Ek: k*y^2=x^3+A*x^2+B*x+C. See ?ellQ_ellrank for the format of the output.");
   addhelp(ell2descent_viaisog,
-    "ell2descent_viaisog(E,help=[]): E is an elliptic curve of the form [0,a,0,b,0], with a, b integers. Performs a 2-descent via isogeny on E. See ?ellrank for the format of the output.");
-  addhelp(ellrank,
-    "ellrank(E,help=[]): E is any elliptic curve defined over Q. Returns a vector [r,s,v], where r is a lower bound for the rank of E, s is the rank of its 2-Selmer group and v is a list of independant points in E(Q)/2E(Q). If help is a vector of nontrivial points on E, the result might be faster. This function might be used in conjunction with elltors2(E). See also ?default_ellQ");
+    "ell2descent_viaisog(E,help=[]): E is an elliptic curve of the form [0,a,0,b,0], with a, b integers. Performs a 2-descent via isogeny on E. See ?ellQ_ellrank for the format of the output.");
+  addhelp(ellQ_ellrank,
+    "ellQ_ellrank(E,help=[]): E is any elliptic curve defined over Q. Returns a vector [r,s,v], where r is a lower bound for the rank of E, s is the rank of its 2-Selmer group and v is a list of independant points in E(Q)/2E(Q). If help is a vector of nontrivial points on E, the result might be faster. This function might be used in conjunction with elltors2(E). See also ?default_ellQ");
   addhelp(ellhalf,
     "ellhalf(E,P): returns the vector of all points Q on the elliptic curve E such that 2Q = P");
   addhelp(ellredgen,
@@ -2143,7 +2143,7 @@ if( DEBUGLEVEL_ell >= 3, print("   end of ell2descent_viaisog"));
 
 \\                  others
   addhelp(default_ellQ,
-    "default_ellQ(DEBUGLEVEL_ell, LIM1, LIM3, LIMTRIV, ELLREDGENFLAG, COMPLETE, MAXPROB, LIMBIGPRIME): set the value of the global variables used for ellrank() and other related functions. DEBUGLEVEL_ell: 0-5: choose the quantity of information printed during the computation (default=0: print nothing); LIM1 (resp LIM3): search limit for easy (resp hard) points on quartics; LIMTRIV: search limit for trivial points on elliptic curves; ELLREDGENFLAG: if != 0, try to reduce the generators at the end; COMPLETE: if != 0 and full 2-torsion, use complete 2-descent, otherwise via 2-isogeny; MAXPROB, LIMBIGPRIME: technical.");
+    "default_ellQ(DEBUGLEVEL_ell, LIM1, LIM3, LIMTRIV, ELLREDGENFLAG, COMPLETE, MAXPROB, LIMBIGPRIME): set the value of the global variables used for ellQ_ellrank() and other related functions. DEBUGLEVEL_ell: 0-5: choose the quantity of information printed during the computation (default=0: print nothing); LIM1 (resp LIM3): search limit for easy (resp hard) points on quartics; LIMTRIV: search limit for trivial points on elliptic curves; ELLREDGENFLAG: if != 0, try to reduce the generators at the end; COMPLETE: if != 0 and full 2-torsion, use complete 2-descent, otherwise via 2-isogeny; MAXPROB, LIMBIGPRIME: technical.");
 /*  addhelp(DEBUGLEVEL_ell,
     "DEBUGLEVEL_ell: Choose a higher value of this global variable to have more details of the computations printed during the 2-descent algorithm. 0 = don't print anything; 1 = (default) just print the result; 2 = print more details including the Selmer group and the nontrivial quartics.");
 */
diff --git a/src/sage/ext_data/pari/simon/qfsolve.gp b/src/sage/ext_data/pari/simon/qfsolve.gp
index 501fb50828..2107288c1d 100644
--- a/src/sage/ext_data/pari/simon/qfsolve.gp
+++ b/src/sage/ext_data/pari/simon/qfsolve.gp
@@ -434,146 +434,6 @@ my(cc);
 return([U3~*G3*U3,red[2]*U1*U2*U3]);
 }
 
-\\ \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
-\\        QUADRATIC FORMS MINIMIZATION         \\
-\\ \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
-
-\\ Minimization of the quadratic form G, with nonzero determinant.
-\\ of dimension n>=2.
-\\ G must by symmetric and have integral coefficients.
-\\ Returns [G',U,factd] with U in GLn(Q) such that G'=U~*G*U*constant
-\\ is integral and has minimal determinant.
-\\ In dimension 3 or 4, may return a prime p
-\\ if the reduction at p is impossible because of the local non solvability.
-\\ If given, factdetG must be equal to factor(abs(det(G))).
-{qfminimize(G,factdetG) =
-my(factd,U,Ker,Ker2,sol,aux,di);
-my(p);
-my(n,lf,i,vp,dimKer,dimKer2,m);
-
-  n = length(G);
-  factd = matrix(0,2);
-  if( !factdetG, factdetG = factor(matdet(G)));
-
-  lf = length(factdetG[,1]);
-  i = 1; U = matid(n);
-
-  while(i <= lf,
-    vp = factdetG[i,2];
-    if( vp == 0, i++; next);
-    p = factdetG[i,1];
-    if( p == -1, i++; next);
-if( DEBUGLEVEL_qfsolve >= 4, print("    p = ",p,"^",vp));
-
-\\ The case vp = 1 can be minimized only if n is odd.
-    if( vp == 1 && n%2 == 0,
-      factd = concat(factd~, Mat([p,1])~)~;
-      i++; next
-    );
-    Ker = kermodp(G,p); dimKer = Ker[1]; Ker = Ker[2];
-
-\\ Rem: we must have dimKer <= vp
-if( DEBUGLEVEL_qfsolve >= 4, print("    dimKer = ",dimKer));
-\\ trivial case: dimKer = n
-    if( dimKer == n, 
-if( DEBUGLEVEL_qfsolve >= 4, print("     case 0: dimKer = n"));
-      G /= p;
-      factdetG[i,2] -= n;
-      next
-    );
-    G = Ker~*G*Ker;
-    U = U*Ker;
-
-\\ 1st case: dimKer < vp
-\\ then the kernel mod p contains a kernel mod p^2
-    if( dimKer < vp,
-if( DEBUGLEVEL_qfsolve >= 4, print("    case 1: dimker < vp"));
-      if( dimKer == 1,
-\\        G[,1] /= p; G[1,] /= p;
-        G[,1] /= p; G[1,] = G[1,]/p;
-        U[,1] /= p;
-        factdetG[i,2] -= 2
-      , 
-        Ker2 = kermodp(matrix(dimKer,dimKer,j,k,G[j,k]/p),p);
-        dimKer2 = Ker2[1]; Ker2 = Ker2[2];
-        for( j = 1, dimKer2, Ker2[,j] /= p);
-        Ker2 = matdiagonalblock([Ker2,matid(n-dimKer)]);
-        G = Ker2~*G*Ker2;
-        U = U*Ker2;
-        factdetG[i,2] -= 2*dimKer2
-);
-
-if( DEBUGLEVEL_qfsolve >= 4, print("    end of case 1"));
-      next
-    );
-
-\\ Now, we have vp = dimKer 
-\\ 2nd case: the dimension of the kernel is >=2
-\\ and contains an element of norm 0 mod p^2
-
-\\ search for an element of norm p^2... in the kernel
-    if( dimKer > 2 || 
-       (dimKer == 2 && issquare( di = Mod((G[1,2]^2-G[1,1]*G[2,2])/p^2,p))),
-      if( dimKer > 2,
-if( DEBUGLEVEL_qfsolve >= 4, print("    case 2.1"));
-        dimKer = 3;
-        sol = qfsolvemodp(matrix(3,3,j,k,G[j,k]/p),p)
-      ,
-if( DEBUGLEVEL_qfsolve >= 4, print("    case 2.2"));
-        if( G[1,1]%p^2 == 0, 
-          sol = [1,0]~
-        , sol = [-G[1,2]/p+sqrt(di),Mod(G[1,1]/p,p)]~
-        )
-      );
-      sol = centerlift(sol);
-      sol /= content(sol);
-if( DEBUGLEVEL_qfsolve >= 4, print("    sol = ",sol));
-      Ker = vectorv(n, j, if( j<= dimKer, sol[j], 0)); \\ fill with 0's
-      Ker = completebasis(Ker,1);
-      Ker[,n] /= p;
-      G = Ker~*G*Ker;
-      U = U*Ker;
-      factdetG[i,2] -= 2;
-if( DEBUGLEVEL_qfsolve >= 4, print("    end of case 2"));
-      next
-    );
-
-\\ Now, we have vp = dimKer <= 2 
-\\   and the kernel contains no vector with norm p^2...
-
-\\ In some cases, exchanging the kernel and the image
-\\ makes the minimization easy.
-
-    m = (n-1)\2-1;
-    if( ( vp == 1 && issquare(Mod(-(-1)^m*matdet(G)/G[1,1],p)))
-     || ( vp == 2 && n%2 == 1 && n >= 5)
-     || ( vp == 2 && n%2 == 0 && !issquare(Mod((-1)^m*matdet(G)/p^2,p)))
-    , 
-if( DEBUGLEVEL_qfsolve >= 4, print("    case 3"));
-      Ker = matid(n);
-      for( j = dimKer+1, n, Ker[j,j] = p);
-      G = Ker~*G*Ker/p;
-      U = U*Ker;
-      factdetG[i,2] -= 2*dimKer-n;
-if( DEBUGLEVEL_qfsolve >= 4, print("    end of case 3"));
-      next
-    );
-
-\\ Minimization was not possible se far.
-\\ If n == 3 or 4, this proves the local non-solubility at p.
-    if( n == 3 || n == 4, 
-if( DEBUGLEVEL_qfsolve >= 1, print(" no local solution at ",p));
-      return(p));
-
-if( DEBUGLEVEL_qfsolve >= 4, print("    prime ",p," finished"));
-    factd = concat(factd~,Mat([p,vp])~)~;
-    i++
-  );
-\\ apply LLL to avoid coefficients explosion
-  aux = qflll(U/content(U));
-return([aux~*G*aux,U*aux,factd]);
-}
-
 \\ \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
 \\          CLASS GROUP COMPUTATIONS           \\
 \\ \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
diff --git a/src/sage/geometry/polyhedron/backend_field.py b/src/sage/geometry/polyhedron/backend_field.py
index 93c46c6630..996d6c1a7a 100644
--- a/src/sage/geometry/polyhedron/backend_field.py
+++ b/src/sage/geometry/polyhedron/backend_field.py
@@ -275,7 +275,7 @@ class Polyhedron_field(Polyhedron_base):
              An inequality (-0.1419794359520263?, -1.698172434277148?) x + 1.200789243901438? >= 0,
              An inequality (0.3001973109753594?, 0.600394621950719?) x - 0.4245431085692869? >= 0)
             sage: p.Vrepresentation()                                           # optional - sage.rings.number_field
-            (A vertex at (0.?e-15, 0.707106781186548?),
+            (A vertex at (0.?e-16, 0.7071067811865475?),
              A vertex at (1.414213562373095?, 0),
              A vertex at (4.000000000000000?, 0.372677996249965?))
         """
@@ -318,7 +318,7 @@ class Polyhedron_field(Polyhedron_base):
              An inequality (-0.1419794359520263?, -1.698172434277148?) x + 1.200789243901438? >= 0,
              An inequality (0.3001973109753594?, 0.600394621950719?) x - 0.4245431085692869? >= 0)
             sage: p.Vrepresentation()                                           # optional - sage.rings.number_field
-            (A vertex at (0.?e-15, 0.707106781186548?),
+            (A vertex at (0.?e-16, 0.7071067811865475?),
              A vertex at (1.414213562373095?, 0),
              A vertex at (4.000000000000000?, 0.372677996249965?))
         """
diff --git a/src/sage/groups/matrix_gps/isometries.py b/src/sage/groups/matrix_gps/isometries.py
index f9111a2c92..cca45e7175 100644
--- a/src/sage/groups/matrix_gps/isometries.py
+++ b/src/sage/groups/matrix_gps/isometries.py
@@ -11,11 +11,11 @@ EXAMPLES::
     sage: L = IntegralLattice("D4")
     sage: O = L.orthogonal_group()
     sage: O
-    Group of isometries with 5 generators (
-    [-1  0  0  0]  [0 0 0 1]  [-1 -1 -1 -1]  [ 1  1  0  0]  [ 1  0  0  0]
-    [ 0 -1  0  0]  [0 1 0 0]  [ 0  0  1  0]  [ 0  0  1  0]  [-1 -1 -1 -1]
-    [ 0  0 -1  0]  [0 0 1 0]  [ 0  1  0  1]  [ 0  1  0  1]  [ 0  0  1  0]
-    [ 0  0  0 -1], [1 0 0 0], [ 0 -1 -1  0], [ 0 -1 -1  0], [ 0  0  0  1]
+    Group of isometries with 3 generators (
+    [0 0 0 1]  [ 1  1  0  0]  [ 1  0  0  0]
+    [0 1 0 0]  [ 0  0  1  0]  [-1 -1 -1 -1]
+    [0 0 1 0]  [ 0  1  0  1]  [ 0  0  1  0]
+    [1 0 0 0], [ 0 -1 -1  0], [ 0  0  0  1]
     )
 
 Basic functionality is provided by GAP::
diff --git a/src/sage/interfaces/genus2reduction.py b/src/sage/interfaces/genus2reduction.py
index 56ae04b235..7a4794daf2 100644
--- a/src/sage/interfaces/genus2reduction.py
+++ b/src/sage/interfaces/genus2reduction.py
@@ -143,31 +143,31 @@ class ReductionData(SageObject):
        sur un corps de valuation discrète", Trans. AMS 348 (1996),
        4577-4610, Section 7.2, Proposition 4).
     """
-    def __init__(self, pari_result, P, Q, minimal_equation, minimal_disc,
-                 local_data, conductor, prime_to_2_conductor_only):
+    def __init__(self, pari_result, P, Q, Pmin, Qmin, minimal_disc,
+                 local_data, conductor):
         self.pari_result = pari_result
         self.P = P
         self.Q = Q
-        self.minimal_equation = minimal_equation
+        self.Pmin = Pmin
+        self.Qmin = Qmin
         self.minimal_disc = minimal_disc
         self.local_data = local_data
         self.conductor = conductor
-        self.prime_to_2_conductor_only = prime_to_2_conductor_only
 
     def _repr_(self):
-        if self.prime_to_2_conductor_only:
-            ex = ' (away from 2)'
-        else:
-            ex = ''
         if self.Q == 0:
             yterm = ''
         else:
             yterm = '+ (%s)*y '%self.Q
+
         s = 'Reduction data about this proper smooth genus 2 curve:\n'
         s += '\ty^2 %s= %s\n'%(yterm, self.P)
-        s += 'A Minimal Equation (away from 2):\n\ty^2 = %s\n'%self.minimal_equation
-        s += 'Minimal Discriminant (away from 2):  %s\n'%self.minimal_disc
-        s += 'Conductor%s: %s\n'%(ex, self.conductor)
+        if self.Qmin:
+            s += 'A Minimal Equation:\n\ty^2 + (%s)y = %s\n'%(self.Qmin, self.Pmin)
+        else:
+            s += 'A Minimal Equation:\n\ty^2 = %s\n'%self.Pmin
+        s += 'Minimal Discriminant: %s\n'%self.minimal_disc
+        s += 'Conductor: %s\n'%self.conductor
         s += 'Local Data:\n%s'%self._local_data_str()
         return s
 
@@ -242,17 +242,7 @@ class Genus2reduction(SageObject):
         sage: factor(R.conductor)
         5^4 * 2267
 
-    This means that only the odd part of the conductor is known.
-
-    ::
-
-        sage: R.prime_to_2_conductor_only
-        True
-
-    The discriminant is always minimal away from 2, but possibly not at
-    2.
-
-    ::
+    The discriminant is always minimal::
 
         sage: factor(R.minimal_disc)
         2^3 * 5^5 * 2267
@@ -264,10 +254,10 @@ class Genus2reduction(SageObject):
         sage: R
         Reduction data about this proper smooth genus 2 curve:
             y^2 + (x^3 - 2*x^2 - 2*x + 1)*y = -5*x^5
-        A Minimal Equation (away from 2):
-            y^2 = x^6 - 240*x^4 - 2550*x^3 - 11400*x^2 - 24100*x - 19855
-        Minimal Discriminant (away from 2):  56675000
-        Conductor (away from 2): 1416875
+        A Minimal Equation:
+            y^2 ...
+        Minimal Discriminant: 56675000
+        Conductor: 1416875
         Local Data:
             p=2
             (potential) stable reduction:  (II), j=1
@@ -293,10 +283,10 @@ class Genus2reduction(SageObject):
         sage: genus2reduction(0, x^6 + 3*x^3 + 63)
         Reduction data about this proper smooth genus 2 curve:
                 y^2 = x^6 + 3*x^3 + 63
-        A Minimal Equation (away from 2):
-                y^2 = x^6 + 3*x^3 + 63
-        Minimal Discriminant (away from 2):  10628388316852992
-        Conductor (away from 2): 2893401
+        A Minimal Equation:
+                y^2 ...
+        Minimal Discriminant: -10628388316852992
+        Conductor: 2893401
         Local Data:
                 p=2
                 (potential) stable reduction:  (V), j1+j2=0, j1*j2=0
@@ -327,9 +317,9 @@ class Genus2reduction(SageObject):
         sage: genus2reduction(x^3-x^2-1, x^2 - x)
         Reduction data about this proper smooth genus 2 curve:
                 y^2 + (x^3 - x^2 - 1)*y = x^2 - x
-        A Minimal Equation (away from 2):
-                y^2 = x^6 + 58*x^5 + 1401*x^4 + 18038*x^3 + 130546*x^2 + 503516*x + 808561
-        Minimal Discriminant (away from 2):  169
+        A Minimal Equation:
+                y^2 ...
+        Minimal Discriminant: -169
         Conductor: 169
         Local Data:
                 p=13
@@ -370,10 +360,10 @@ class Genus2reduction(SageObject):
             sage: genus2reduction(x^3 - 2*x^2 - 2*x + 1, -5*x^5)
             Reduction data about this proper smooth genus 2 curve:
                     y^2 + (x^3 - 2*x^2 - 2*x + 1)*y = -5*x^5
-            A Minimal Equation (away from 2):
-                    y^2 = x^6 - 240*x^4 - 2550*x^3 - 11400*x^2 - 24100*x - 19855
-            Minimal Discriminant (away from 2):  56675000
-            Conductor (away from 2): 1416875
+            A Minimal Equation:
+                    y^2 ...
+            Minimal Discriminant: 56675000
+            Conductor: 1416875
             Local Data:
                     p=2
                     (potential) stable reduction:  (II), j=1
@@ -389,9 +379,9 @@ class Genus2reduction(SageObject):
             sage: genus2reduction(x^2 + 1, -5*x^5)
             Reduction data about this proper smooth genus 2 curve:
                     y^2 + (x^2 + 1)*y = -5*x^5
-            A Minimal Equation (away from 2):
-                    y^2 = -20*x^5 + x^4 + 2*x^2 + 1
-            Minimal Discriminant (away from 2):  48838125
+            A Minimal Equation:
+                    y^2 ...
+            Minimal Discriminant: 48838125
             Conductor: 32025
             Local Data:
                     p=3
@@ -412,9 +402,9 @@ class Genus2reduction(SageObject):
             sage: genus2reduction(x^3 + x^2 + x,-2*x^5 + 3*x^4 - x^3 - x^2 - 6*x - 2)
             Reduction data about this proper smooth genus 2 curve:
                     y^2 + (x^3 + x^2 + x)*y = -2*x^5 + 3*x^4 - x^3 - x^2 - 6*x - 2
-            A Minimal Equation (away from 2):
-                    y^2 = x^6 + 18*x^3 + 36*x^2 - 27
-            Minimal Discriminant (away from 2):  1520984142
+            A Minimal Equation:
+                    y^2 ...
+            Minimal Discriminant: 1520984142
             Conductor: 954
             Local Data:
                     p=2
@@ -436,18 +426,10 @@ class Genus2reduction(SageObject):
             raise ValueError("Q (=%s) must have degree at most 3" % Q)
 
         res = pari.genus2red([P, Q])
-
         conductor = ZZ(res[0])
-        minimal_equation = R(res[2])
-
-        minimal_disc = QQ(res[2].poldisc()).abs()
-        if minimal_equation.degree() == 5:
-            minimal_disc *= minimal_equation[5]**2
-        # Multiply with suitable power of 2 of the form 2^(2*(d-1) - 12)
-        b = 2 * (minimal_equation.degree() - 1)
-        k = QQ((12 - minimal_disc.valuation(2), b)).ceil()
-        minimal_disc >>= 12 - b*k
-        minimal_disc = ZZ(minimal_disc)
+        Pmin = R(res[2][0])
+        Qmin = R(res[2][1])
+        minimal_disc = ZZ(pari.hyperelldisc(res[2]))
 
         local_data = {}
         for red in res[3]:
@@ -468,9 +450,7 @@ class Genus2reduction(SageObject):
 
             local_data[p] = data
 
-        prime_to_2_conductor_only = (-1 in res[1].component(2))
-        return ReductionData(res, P, Q, minimal_equation, minimal_disc, local_data,
-                             conductor, prime_to_2_conductor_only)
+        return ReductionData(res, P, Q, Pmin, Qmin, minimal_disc, local_data, conductor)
 
     def __reduce__(self):
         return _reduce_load_genus2reduction, tuple([])
diff --git a/src/sage/lfunctions/dokchitser.py b/src/sage/lfunctions/dokchitser.py
index fec450d7bc..236402c293 100644
--- a/src/sage/lfunctions/dokchitser.py
+++ b/src/sage/lfunctions/dokchitser.py
@@ -337,6 +337,7 @@ class Dokchitser(SageObject):
             # After init_coeffs is called, future calls to this method should
             # return the full output for further parsing
             raise RuntimeError("unable to create L-series, due to precision or other limits in PARI")
+        t = t.replace("  *** _^_: Warning: normalizing a series with 0 leading term.\n", "")
         return t
 
     def __check_init(self):
diff --git a/src/sage/lfunctions/pari.py b/src/sage/lfunctions/pari.py
index da783d2831..ba93f7a480 100644
--- a/src/sage/lfunctions/pari.py
+++ b/src/sage/lfunctions/pari.py
@@ -328,7 +328,7 @@ def lfun_eta_quotient(scalings, exponents):
         0.0374412812685155
 
         sage: lfun_eta_quotient([6], [4])
-        [[Vecsmall([7]), [Vecsmall([6]), Vecsmall([4])]], 0, [0, 1], 2, 36, 1]
+        [[Vecsmall([7]), [Vecsmall([6]), Vecsmall([4]), 0]], 0, [0, 1], 2, 36, 1]
 
         sage: lfun_eta_quotient([2, 1, 4], [5, -2, -2])
         Traceback (most recent call last):
diff --git a/src/sage/libs/pari/tests.py b/src/sage/libs/pari/tests.py
index e5a2aa2517..0efcb15de0 100644
--- a/src/sage/libs/pari/tests.py
+++ b/src/sage/libs/pari/tests.py
@@ -356,7 +356,7 @@ Constructors::
     [2, 4]~*x + [1, 3]~
 
     sage: pari(3).Qfb(7, 1)
-    Qfb(3, 7, 1, 0.E-19)
+    Qfb(3, 7, 1)
     sage: pari(3).Qfb(7, 2)
     Traceback (most recent call last):
     ...
@@ -512,7 +512,7 @@ Basic functions::
     sage: pari('sqrt(-2)').frac()
     Traceback (most recent call last):
     ...
-    PariError: incorrect type in gfloor (t_COMPLEX)
+    PariError: incorrect type in gfrac (t_COMPLEX)
 
     sage: pari('1+2*I').imag()
     2
diff --git a/src/sage/modular/cusps_nf.py b/src/sage/modular/cusps_nf.py
index 25d93cac92..157ebabe29 100644
--- a/src/sage/modular/cusps_nf.py
+++ b/src/sage/modular/cusps_nf.py
@@ -1220,7 +1220,7 @@ def units_mod_ideal(I):
         sage: I = k.ideal(5, a + 1)
         sage: units_mod_ideal(I)
         [1,
-        2*a^2 + 4*a - 1,
+        -2*a^2 - 4*a + 1,
         ...]
 
     ::
diff --git a/src/sage/modular/modform_hecketriangle/hecke_triangle_group_element.py b/src/sage/modular/modform_hecketriangle/hecke_triangle_group_element.py
index a881336596..090d1bfaf0 100644
--- a/src/sage/modular/modform_hecketriangle/hecke_triangle_group_element.py
+++ b/src/sage/modular/modform_hecketriangle/hecke_triangle_group_element.py
@@ -43,7 +43,7 @@ def coerce_AA(p):
         sage: AA(p)._exact_field()
         Number Field in a with defining polynomial y^8 ... with a in ...
         sage: coerce_AA(p)._exact_field()
-        Number Field in a with defining polynomial y^4 - 1910*y^2 - 3924*y + 681058 with a in 39.710518724...?
+        Number Field in a with defining polynomial y^4 - 1910*y^2 - 3924*y + 681058 with a in ...?
     """
     el = AA(p)
     el.simplify()
diff --git a/src/sage/modular/modsym/p1list_nf.py b/src/sage/modular/modsym/p1list_nf.py
index 222caacca8..f9d969732c 100644
--- a/src/sage/modular/modsym/p1list_nf.py
+++ b/src/sage/modular/modsym/p1list_nf.py
@@ -58,7 +58,7 @@ Lift an MSymbol to a matrix in `SL(2, R)`:
 
     sage: alpha = MSymbol(N, a + 2, 3*a^2)
     sage: alpha.lift_to_sl2_Ok()
-    [-3*a^2 + a + 12, 25*a^2 - 50*a + 100, a + 2, a^2 - 3*a + 3]
+    [-1, 4*a^2 - 13*a + 23, a + 2, 5*a^2 + 3*a - 3]
     sage: Ok = k.ring_of_integers()
     sage: M = Matrix(Ok, 2, alpha.lift_to_sl2_Ok())
     sage: det(M)
@@ -945,11 +945,11 @@ class P1NFList(SageObject):
             sage: N = k.ideal(5, a + 1)
             sage: P = P1NFList(N)
             sage: u = k.unit_group().gens_values(); u
-            [-1, 2*a^2 + 4*a - 1]
+            [-1, -2*a^2 - 4*a + 1]
             sage: P.apply_J_epsilon(4, -1)
             2
             sage: P.apply_J_epsilon(4, u[0], u[1])
-            1
+            5
 
         ::
 
diff --git a/src/sage/modules/free_quadratic_module_integer_symmetric.py b/src/sage/modules/free_quadratic_module_integer_symmetric.py
index a206f0c721..aeb19ab669 100644
--- a/src/sage/modules/free_quadratic_module_integer_symmetric.py
+++ b/src/sage/modules/free_quadratic_module_integer_symmetric.py
@@ -1168,11 +1168,11 @@ class FreeQuadraticModule_integer_symmetric(FreeQuadraticModule_submodule_with_b
             sage: A4 = IntegralLattice("A4")
             sage: Aut = A4.orthogonal_group()
             sage: Aut
-            Group of isometries with 5 generators (
-            [-1  0  0  0]  [0 0 0 1]  [-1 -1 -1  0]  [ 1  0  0  0]  [ 1  0  0  0]
-            [ 0 -1  0  0]  [0 0 1 0]  [ 0  0  0 -1]  [-1 -1 -1 -1]  [ 0  1  0  0]
-            [ 0  0 -1  0]  [0 1 0 0]  [ 0  0  1  1]  [ 0  0  0  1]  [ 0  0  1  1]
-            [ 0  0  0 -1], [1 0 0 0], [ 0  1  0  0], [ 0  0  1  0], [ 0  0  0 -1]
+            Group of isometries with 4 generators (
+            [0 0 0 1]  [-1 -1 -1  0]  [ 1  0  0  0]  [ 1  0  0  0]
+            [0 0 1 0]  [ 0  0  0 -1]  [-1 -1 -1 -1]  [ 0  1  0  0]
+            [0 1 0 0]  [ 0  0  1  1]  [ 0  0  0  1]  [ 0  0  1  1]
+            [1 0 0 0], [ 0  1  0  0], [ 0  0  1  0], [ 0  0  0 -1]
             )
 
         The group acts from the right on the lattice and its discriminant group::
@@ -1180,19 +1180,19 @@ class FreeQuadraticModule_integer_symmetric(FreeQuadraticModule_submodule_with_b
             sage: x = A4.an_element()
             sage: g = Aut.an_element()
             sage: g
-            [ 1  1  1  0]
-            [ 0  0 -1  0]
-            [ 0  0  1  1]
-            [ 0 -1 -1 -1]
+            [-1 -1 -1  0]
+            [ 0  0  1  0]
+            [ 0  0 -1 -1]
+            [ 0  1  1  1]
             sage: x*g
-            (1, 1, 1, 0)
+            (-1, -1, -1, 0)
             sage: (x*g).parent()==A4
             True
             sage: (g*x).parent()
             Vector space of dimension 4 over Rational Field
             sage: y = A4.discriminant_group().an_element()
             sage: y*g
-            (1)
+            (4)
 
         If the group is finite we can compute the usual things::
 
@@ -1208,10 +1208,10 @@ class FreeQuadraticModule_integer_symmetric(FreeQuadraticModule_submodule_with_b
 
             sage: A2 = IntegralLattice(matrix.identity(3),Matrix(ZZ,2,3,[1,-1,0,0,1,-1]))
             sage: A2.orthogonal_group()
-            Group of isometries with 3 generators (
-            [-1/3  2/3  2/3]  [ 2/3  2/3 -1/3]  [1 0 0]
-            [ 2/3 -1/3  2/3]  [ 2/3 -1/3  2/3]  [0 0 1]
-            [ 2/3  2/3 -1/3], [-1/3  2/3  2/3], [0 1 0]
+            Group of isometries with 2 generators (
+            [ 2/3  2/3 -1/3]  [1 0 0]
+            [ 2/3 -1/3  2/3]  [0 0 1]
+            [-1/3  2/3  2/3], [0 1 0]
             )
 
         It can be negative definite as well::
diff --git a/src/sage/quadratic_forms/binary_qf.py b/src/sage/quadratic_forms/binary_qf.py
index cfa3ada73e..5ac823bc6c 100755
--- a/src/sage/quadratic_forms/binary_qf.py
+++ b/src/sage/quadratic_forms/binary_qf.py
@@ -141,7 +141,7 @@ class BinaryQF(SageObject):
                   and a.degree() == 2 and a.parent().ngens() == 2):
                 x, y = a.parent().gens()
                 a, b, c = [a.monomial_coefficient(mon) for mon in [x**2, x*y, y**2]]
-            elif isinstance(a, pari_gen) and a.type() in ('t_QFI', 't_QFR'):
+            elif isinstance(a, pari_gen) and a.type() in ('t_QFI', 't_QFR', 't_QFB'):
                 # a has 3 or 4 components
                 a, b, c = a[0], a[1], a[2]
         try:
diff --git a/src/sage/quadratic_forms/genera/genus.py b/src/sage/quadratic_forms/genera/genus.py
index 8290b6c4fa..0fc43f33c6 100644
--- a/src/sage/quadratic_forms/genera/genus.py
+++ b/src/sage/quadratic_forms/genera/genus.py
@@ -3088,8 +3088,8 @@ class GenusSymbol_global_ring():
             sage: G = Genus(matrix(ZZ, 3, [6,3,0, 3,6,0, 0,0,2]))
             sage: G.representatives()
             (
-            [2 0 0]  [ 2 -1  0]
-            [0 6 3]  [-1  2  0]
+            [2 0 0]  [ 2  1  0]
+            [0 6 3]  [ 1  2  0]
             [0 3 6], [ 0  0 18]
             )
 
diff --git a/src/sage/quadratic_forms/qfsolve.py b/src/sage/quadratic_forms/qfsolve.py
index ddde95e04f..d5e15d9f83 100644
--- a/src/sage/quadratic_forms/qfsolve.py
+++ b/src/sage/quadratic_forms/qfsolve.py
@@ -70,7 +70,7 @@ def qfsolve(G):
 
         sage: M = Matrix(QQ, [[3, 0, 0, 0], [0, 5, 0, 0], [0, 0, -7, 0], [0, 0, 0, -11]])
         sage: qfsolve(M)
-        (3, -4, -3, -2)
+        (3, 4, -3, -2)
     """
     ret = G.__pari__().qfsolve()
     if ret.type() == 't_COL':
diff --git a/src/sage/quadratic_forms/quadratic_form__automorphisms.py b/src/sage/quadratic_forms/quadratic_form__automorphisms.py
index c36c667e3b..3d72cf3be1 100644
--- a/src/sage/quadratic_forms/quadratic_form__automorphisms.py
+++ b/src/sage/quadratic_forms/quadratic_form__automorphisms.py
@@ -300,9 +300,9 @@ def automorphism_group(self):
         sage: Q = DiagonalQuadraticForm(ZZ, [1,1,1])
         sage: Q.automorphism_group()
         Matrix group over Rational Field with 3 generators (
-        [-1  0  0]  [0 0 1]  [ 0  0  1]
-        [ 0 -1  0]  [0 1 0]  [-1  0  0]
-        [ 0  0 -1], [1 0 0], [ 0  1  0]
+        [ 0  0  1]  [1 0 0]  [ 1  0  0]
+        [-1  0  0]  [0 0 1]  [ 0 -1  0]
+        [ 0  1  0], [0 1 0], [ 0  0  1]
         )
 
     ::
diff --git a/src/sage/rings/finite_rings/finite_field_prime_modn.py b/src/sage/rings/finite_rings/finite_field_prime_modn.py
index f2a91186cd..6b0f0f990e 100644
--- a/src/sage/rings/finite_rings/finite_field_prime_modn.py
+++ b/src/sage/rings/finite_rings/finite_field_prime_modn.py
@@ -111,7 +111,7 @@ class FiniteField_prime_modn(FiniteField_generic, integer_mod_ring.IntegerModRin
             sage: RF13 = K.residue_field(pp)
             sage: RF13.hom([GF(13)(1)])
             Ring morphism:
-             From: Residue field of Fractional ideal (w + 18)
+             From: Residue field of Fractional ideal (-w - 18)
              To:   Finite Field of size 13
              Defn: 1 |--> 1
 
diff --git a/src/sage/rings/finite_rings/residue_field.pyx b/src/sage/rings/finite_rings/residue_field.pyx
index 7596f2a302..1e1869f1b1 100644
--- a/src/sage/rings/finite_rings/residue_field.pyx
+++ b/src/sage/rings/finite_rings/residue_field.pyx
@@ -20,13 +20,13 @@ monogenic (i.e., 2 is an essential discriminant divisor)::
 
     sage: K.<a> = NumberField(x^3 + x^2 - 2*x + 8)
     sage: F = K.factor(2); F
-    (Fractional ideal (1/2*a^2 - 1/2*a + 1)) * (Fractional ideal (-a^2 + 2*a - 3)) * (Fractional ideal (-3/2*a^2 + 5/2*a - 4))
+    (Fractional ideal (-1/2*a^2 + 1/2*a - 1)) * (Fractional ideal (-a^2 + 2*a - 3)) * (Fractional ideal (3/2*a^2 - 5/2*a + 4))
     sage: F[0][0].residue_field()
-    Residue field of Fractional ideal (1/2*a^2 - 1/2*a + 1)
+    Residue field of Fractional ideal (-1/2*a^2 + 1/2*a - 1)
     sage: F[1][0].residue_field()
     Residue field of Fractional ideal (-a^2 + 2*a - 3)
     sage: F[2][0].residue_field()
-    Residue field of Fractional ideal (-3/2*a^2 + 5/2*a - 4)
+    Residue field of Fractional ideal (3/2*a^2 - 5/2*a + 4)
 
 We can also form residue fields from `\ZZ`::
 
@@ -258,9 +258,9 @@ class ResidueFieldFactory(UniqueFactory):
     the index of ``ZZ[a]`` in the maximal order for all ``a``::
 
         sage: K.<a> = NumberField(x^3 + x^2 - 2*x + 8); P = K.ideal(2).factor()[0][0]; P
-        Fractional ideal (1/2*a^2 - 1/2*a + 1)
+        Fractional ideal (-1/2*a^2 + 1/2*a - 1)
         sage: F = K.residue_field(P); F
-        Residue field of Fractional ideal (1/2*a^2 - 1/2*a + 1)
+        Residue field of Fractional ideal (-1/2*a^2 + 1/2*a - 1)
         sage: F(a)
         0
         sage: B = K.maximal_order().basis(); B
@@ -270,7 +270,7 @@ class ResidueFieldFactory(UniqueFactory):
         sage: F(B[2])
         0
         sage: F
-        Residue field of Fractional ideal (1/2*a^2 - 1/2*a + 1)
+        Residue field of Fractional ideal (-1/2*a^2 + 1/2*a - 1)
         sage: F.degree()
         1
 
@@ -730,15 +730,15 @@ class ResidueField_generic(Field):
         EXAMPLES::
 
             sage: I = QQ[3^(1/3)].factor(5)[1][0]; I
-            Fractional ideal (-a + 2)
+            Fractional ideal (a - 2)
             sage: k = I.residue_field(); k
-            Residue field of Fractional ideal (-a + 2)
+            Residue field of Fractional ideal (a - 2)
             sage: f = k.lift_map(); f
             Lifting map:
-              From: Residue field of Fractional ideal (-a + 2)
+              From: Residue field of Fractional ideal (a - 2)
               To:   Maximal Order in Number Field in a with defining polynomial x^3 - 3 with a = 1.442249570307409?
             sage: f.domain()
-            Residue field of Fractional ideal (-a + 2)
+            Residue field of Fractional ideal (a - 2)
             sage: f.codomain()
             Maximal Order in Number Field in a with defining polynomial x^3 - 3 with a = 1.442249570307409?
             sage: f(k.0)
@@ -768,7 +768,7 @@ class ResidueField_generic(Field):
 
             sage: K.<a> = NumberField(x^3-11)
             sage: F = K.ideal(37).factor(); F
-            (Fractional ideal (37, a + 9)) * (Fractional ideal (37, a + 12)) * (Fractional ideal (2*a - 5))
+            (Fractional ideal (37, a + 9)) * (Fractional ideal (37, a + 12)) * (Fractional ideal (-2*a + 5))
             sage: k = K.residue_field(F[0][0])
             sage: l = K.residue_field(F[1][0])
             sage: k == l
@@ -846,7 +846,7 @@ cdef class ReductionMap(Map):
             sage: F.reduction_map()
             Partially defined reduction map:
               From: Number Field in a with defining polynomial x^3 + x^2 - 2*x + 8
-              To:   Residue field of Fractional ideal (1/2*a^2 - 1/2*a + 1)
+              To:   Residue field of Fractional ideal (-1/2*a^2 + 1/2*a - 1)
 
             sage: K.<theta_5> = CyclotomicField(5)
             sage: F = K.factor(7)[0][0].residue_field()
diff --git a/src/sage/rings/number_field/S_unit_solver.py b/src/sage/rings/number_field/S_unit_solver.py
index e99dff850f..759cbfb334 100644
--- a/src/sage/rings/number_field/S_unit_solver.py
+++ b/src/sage/rings/number_field/S_unit_solver.py
@@ -1781,20 +1781,20 @@ def sieve_ordering(SUK, q):
         sage: SUK = K.S_unit_group(S=3)
         sage: sieve_data = list(sieve_ordering(SUK, 19))
         sage: sieve_data[0]
-        (Fractional ideal (xi - 3),
-         Fractional ideal (-2*xi^2 + 3),
+        (Fractional ideal (-2*xi^2 + 3),
+         Fractional ideal (-xi + 3),
          Fractional ideal (2*xi + 1))
 
         sage: sieve_data[1]
-        (Residue field of Fractional ideal (xi - 3),
-         Residue field of Fractional ideal (-2*xi^2 + 3),
+        (Residue field of Fractional ideal (-2*xi^2 + 3),
+         Residue field of Fractional ideal (-xi + 3),
          Residue field of Fractional ideal (2*xi + 1))
 
         sage: sieve_data[2]
-        ([18, 7, 16, 4], [18, 9, 12, 8], [18, 3, 10, 10])
+        ([18, 12, 16, 8], [18, 16, 10, 4], [18, 10, 12, 10])
 
         sage: sieve_data[3]
-        (486, 648, 11664)
+        (648, 2916, 3888)
     """
 
     K = SUK.number_field()
diff --git a/src/sage/rings/number_field/bdd_height.py b/src/sage/rings/number_field/bdd_height.py
index beb047ae02..b7c8c33d0b 100644
--- a/src/sage/rings/number_field/bdd_height.py
+++ b/src/sage/rings/number_field/bdd_height.py
@@ -248,7 +248,7 @@ def bdd_norm_pr_ideal_gens(K, norm_list):
         sage: from sage.rings.number_field.bdd_height import bdd_norm_pr_ideal_gens
         sage: K.<g> = QuadraticField(123)
         sage: bdd_norm_pr_ideal_gens(K, range(5))
-        {0: [0], 1: [1], 2: [-g - 11], 3: [], 4: [2]}
+        {0: [0], 1: [1], 2: [g + 11], 3: [], 4: [2]}
 
     ::
 
diff --git a/src/sage/rings/number_field/class_group.py b/src/sage/rings/number_field/class_group.py
index da255ee6fa..46b98c242e 100644
--- a/src/sage/rings/number_field/class_group.py
+++ b/src/sage/rings/number_field/class_group.py
@@ -221,11 +221,11 @@ class FractionalIdealClass(AbelianGroupWithValuesElement):
             Class group of order 76 with structure C38 x C2
             of Number Field in a with defining polynomial x^2 + 20072
             sage: I = (G.0)^11; I
-            Fractional ideal class (41, 1/2*a + 5)
+            Fractional ideal class (33, 1/2*a + 8)
             sage: J = G(I.ideal()^5); J
-            Fractional ideal class (115856201, 1/2*a + 40407883)
+            Fractional ideal class (39135393, 1/2*a + 13654253)
             sage: J.reduce()
-            Fractional ideal class (57, 1/2*a + 44)
+            Fractional ideal class (73, 1/2*a + 47)
             sage: J == I^5
             True
         """
diff --git a/src/sage/rings/number_field/galois_group.py b/src/sage/rings/number_field/galois_group.py
index 79acd053bb..e060148e4d 100644
--- a/src/sage/rings/number_field/galois_group.py
+++ b/src/sage/rings/number_field/galois_group.py
@@ -944,7 +944,7 @@ class GaloisGroup_v2(GaloisGroup_perm):
             sage: K.<b> = NumberField(x^4 - 2*x^2 + 2, 'a').galois_closure()
             sage: G = K.galois_group()
             sage: [G.artin_symbol(P) for P in K.primes_above(7)]
-            [(1,5)(2,6)(3,7)(4,8), (1,5)(2,6)(3,7)(4,8), (1,4)(2,3)(5,8)(6,7), (1,4)(2,3)(5,8)(6,7)]
+            [(1,4)(2,3)(5,8)(6,7), (1,4)(2,3)(5,8)(6,7), (1,5)(2,6)(3,7)(4,8), (1,5)(2,6)(3,7)(4,8)]
             sage: G.artin_symbol(17)
             Traceback (most recent call last):
             ...
diff --git a/src/sage/rings/number_field/number_field.py b/src/sage/rings/number_field/number_field.py
index cfb71b38ab..ebf0dd4339 100644
--- a/src/sage/rings/number_field/number_field.py
+++ b/src/sage/rings/number_field/number_field.py
@@ -3648,7 +3648,7 @@ class NumberField_generic(WithEqualityById, number_field_base.NumberField):
             sage: L.<b> = K.extension(x^2 - 3, x^2 + 1)
             sage: M.<c> = L.extension(x^2 + 1)
             sage: L.ideal(K.ideal(2, a))
-            Fractional ideal (-a)
+            Fractional ideal (a)
             sage: M.ideal(K.ideal(2, a)) == M.ideal(a*(b - c)/2)
             True
 
@@ -4232,7 +4232,8 @@ class NumberField_generic(WithEqualityById, number_field_base.NumberField):
             (y^2 + 6, Mod(1/6*y, y^2 + 6), Mod(6*y, y^2 + 1/6))
         """
         f = self.absolute_polynomial()._pari_with_name('y')
-        if f.pollead() == f.content().denominator() == 1:
+        f = f * f.content().denominator()
+        if f.pollead() == 1:
             g = f
             alpha = beta = g.variable().Mod(g)
         else:
@@ -4826,7 +4827,7 @@ class NumberField_generic(WithEqualityById, number_field_base.NumberField):
 
             sage: K.<a> = NumberField(2*x^2 - 1/3)
             sage: K._S_class_group_and_units(tuple(K.primes_above(2) + K.primes_above(3)))
-            ([-6*a + 2, 6*a + 3, -1, 12*a + 5], [])
+            ([6*a + 2, 6*a + 3, -1, -12*a + 5], [])
         """
         K_pari = self.pari_bnf(proof=proof)
         S_pari = [p.pari_prime() for p in sorted(set(S))]
@@ -5171,7 +5172,7 @@ class NumberField_generic(WithEqualityById, number_field_base.NumberField):
 
             sage: [K.ideal(g).factor() for g in gens]
             [(Fractional ideal (2, a + 1)) * (Fractional ideal (3, a + 1)),
-            Fractional ideal (-a),
+            Fractional ideal (a),
             (Fractional ideal (2, a + 1))^2,
             1]
 
@@ -5756,7 +5757,7 @@ class NumberField_generic(WithEqualityById, number_field_base.NumberField):
             sage: K.elements_of_norm(3)
             []
             sage: K.elements_of_norm(50)
-            [-7*a + 1, 5*a - 5, 7*a + 1]
+            [-a - 7, 5*a - 5, 7*a + 1]
 
         TESTS:
 
@@ -5868,7 +5869,7 @@ class NumberField_generic(WithEqualityById, number_field_base.NumberField):
             sage: K.factor(1+a)
             Fractional ideal (a + 1)
             sage: K.factor(1+a/5)
-            (Fractional ideal (a + 1)) * (Fractional ideal (-a - 2))^-1 * (Fractional ideal (2*a + 1))^-1 * (Fractional ideal (-3*a - 2))
+            (Fractional ideal (a + 1)) * (Fractional ideal (-a - 2))^-1 * (Fractional ideal (2*a + 1))^-1 * (Fractional ideal (-2*a + 3))
 
         An example over a relative number field::
 
@@ -6474,9 +6475,9 @@ class NumberField_generic(WithEqualityById, number_field_base.NumberField):
             sage: new_basis = k.reduced_basis(prec=120)
             sage: [c.minpoly() for c in new_basis]
             [x - 1,
-             x^2 - x + 1,
+             x^2 + x + 1,
+             x^6 + 3*x^5 - 102*x^4 - 103*x^3 + 10572*x^2 - 59919*x + 127657,
              x^6 + 3*x^5 - 102*x^4 - 103*x^3 + 10572*x^2 - 59919*x + 127657,
-             x^6 - 3*x^5 - 102*x^4 + 315*x^3 + 10254*x^2 - 80955*x + 198147,
              x^3 - 171*x + 848,
              x^6 + 171*x^4 + 1696*x^3 + 29241*x^2 + 145008*x + 719104]
             sage: R = k.order(new_basis)
@@ -7072,7 +7073,7 @@ class NumberField_generic(WithEqualityById, number_field_base.NumberField):
              -a^16 - a^15 - a^14 - a^13 - a^12 - a^11 - a^10 - a^9 - a^8 - a^7 - a^6 - a^5 - a^4 - a^3 - a^2 + 2,
              -2*a^16 + 3*a^15 - 3*a^14 + 3*a^13 - 3*a^12 + a^11 - a^9 + 3*a^8 - 4*a^7 + 5*a^6 - 6*a^5 + 4*a^4 - 3*a^3 + 2*a^2 + 2*a - 4,
              a^15 - a^12 + a^10 - a^9 - 2*a^8 + 3*a^7 + a^6 - 3*a^5 + a^4 + 4*a^3 - 3*a^2 - 2*a + 2,
-             -a^14 - a^13 + a^12 + 2*a^10 + a^8 - 2*a^7 - 2*a^6 + 2*a^3 - a^2 + 2*a - 2)
+             2*a^16 + a^15 - a^11 - 3*a^10 - 4*a^9 - 4*a^8 - 4*a^7 - 5*a^6 - 7*a^5 - 8*a^4 - 6*a^3 - 5*a^2 - 6*a - 7)
 
         TESTS:
 
@@ -7081,7 +7082,7 @@ class NumberField_generic(WithEqualityById, number_field_base.NumberField):
 
             sage: K.<a> = NumberField(1/2*x^2 - 1/6)
             sage: K.units()
-            (-3*a + 2,)
+            (3*a - 2,)
         """
         proof = proof_flag(proof)
 
@@ -7160,7 +7161,7 @@ class NumberField_generic(WithEqualityById, number_field_base.NumberField):
             sage: U.gens()
             (u0, u1, u2, u3, u4, u5, u6, u7, u8)
             sage: U.gens_values()  # result not independently verified
-            [-1, -a^9 - a + 1, -a^16 + a^15 - a^14 + a^12 - a^11 + a^10 + a^8 - a^7 + 2*a^6 - a^4 + 3*a^3 - 2*a^2 + 2*a - 1, 2*a^16 - a^14 - a^13 + 3*a^12 - 2*a^10 + a^9 + 3*a^8 - 3*a^6 + 3*a^5 + 3*a^4 - 2*a^3 - 2*a^2 + 3*a + 4, a^15 + a^14 + 2*a^11 + a^10 - a^9 + a^8 + 2*a^7 - a^5 + 2*a^3 - a^2 - 3*a + 1, -a^16 - a^15 - a^14 - a^13 - a^12 - a^11 - a^10 - a^9 - a^8 - a^7 - a^6 - a^5 - a^4 - a^3 - a^2 + 2, -2*a^16 + 3*a^15 - 3*a^14 + 3*a^13 - 3*a^12 + a^11 - a^9 + 3*a^8 - 4*a^7 + 5*a^6 - 6*a^5 + 4*a^4 - 3*a^3 + 2*a^2 + 2*a - 4, a^15 - a^12 + a^10 - a^9 - 2*a^8 + 3*a^7 + a^6 - 3*a^5 + a^4 + 4*a^3 - 3*a^2 - 2*a + 2, -a^14 - a^13 + a^12 + 2*a^10 + a^8 - 2*a^7 - 2*a^6 + 2*a^3 - a^2 + 2*a - 2]
+            [-1, -a^9 - a + 1, -a^16 + a^15 - a^14 + a^12 - a^11 + a^10 + a^8 - a^7 + 2*a^6 - a^4 + 3*a^3 - 2*a^2 + 2*a - 1, 2*a^16 - a^14 - a^13 + 3*a^12 - 2*a^10 + a^9 + 3*a^8 - 3*a^6 + 3*a^5 + 3*a^4 - 2*a^3 - 2*a^2 + 3*a + 4, a^15 + a^14 + 2*a^11 + a^10 - a^9 + a^8 + 2*a^7 - a^5 + 2*a^3 - a^2 - 3*a + 1, -a^16 - a^15 - a^14 - a^13 - a^12 - a^11 - a^10 - a^9 - a^8 - a^7 - a^6 - a^5 - a^4 - a^3 - a^2 + 2, -2*a^16 + 3*a^15 - 3*a^14 + 3*a^13 - 3*a^12 + a^11 - a^9 + 3*a^8 - 4*a^7 + 5*a^6 - 6*a^5 + 4*a^4 - 3*a^3 + 2*a^2 + 2*a - 4, a^15 - a^12 + a^10 - a^9 - 2*a^8 + 3*a^7 + a^6 - 3*a^5 + a^4 + 4*a^3 - 3*a^2 - 2*a + 2, 2*a^16 + a^15 - a^11 - 3*a^10 - 4*a^9 - 4*a^8 - 4*a^7 - 5*a^6 - 7*a^5 - 8*a^4 - 6*a^3 - 5*a^2 - 6*a - 7]
         """
         proof = proof_flag(proof)
 
diff --git a/src/sage/rings/number_field/number_field_element.pyx b/src/sage/rings/number_field/number_field_element.pyx
index 784c239dc1..aa740069dc 100644
--- a/src/sage/rings/number_field/number_field_element.pyx
+++ b/src/sage/rings/number_field/number_field_element.pyx
@@ -4446,7 +4446,7 @@ cdef class NumberFieldElement(FieldElement):
             sage: f = Qi.embeddings(K)[0]
             sage: a = f(2+3*i) * (2-zeta)^2
             sage: a.descend_mod_power(Qi,2)
-            [-3*i - 2, -2*i + 3]
+            [-2*i + 3, 3*i + 2]
 
         An absolute example::
 
@@ -5124,7 +5124,7 @@ cdef class NumberFieldElement_relative(NumberFieldElement):
         EXAMPLES::
 
             sage: K.<a, b, c> = NumberField([x^2 - 2, x^2 - 3, x^2 - 5])
-            sage: P = K.prime_factors(5)[0]
+            sage: P = K.prime_factors(5)[1]
             sage: (2*a + b - c).valuation(P)
             1
         """
diff --git a/src/sage/rings/number_field/number_field_ideal.py b/src/sage/rings/number_field/number_field_ideal.py
index 5f587556a4..33481fead0 100644
--- a/src/sage/rings/number_field/number_field_ideal.py
+++ b/src/sage/rings/number_field/number_field_ideal.py
@@ -3355,7 +3355,7 @@ def quotient_char_p(I, p):
         []
 
         sage: I = K.factor(13)[0][0]; I
-        Fractional ideal (-3*i - 2)
+        Fractional ideal (-2*i + 3)
         sage: I.residue_class_degree()
         1
         sage: quotient_char_p(I, 13)[0]
diff --git a/src/sage/rings/number_field/number_field_ideal_rel.py b/src/sage/rings/number_field/number_field_ideal_rel.py
index bae36d4b9c..f64bd5b761 100644
--- a/src/sage/rings/number_field/number_field_ideal_rel.py
+++ b/src/sage/rings/number_field/number_field_ideal_rel.py
@@ -272,7 +272,7 @@ class NumberFieldFractionalIdeal_rel(NumberFieldFractionalIdeal):
             sage: L.<b> = K.extension(5*x^2 + 1)
             sage: P = L.primes_above(2)[0]
             sage: P.gens_reduced()
-            (2, 15*a*b + 3*a + 1)
+            (2, -15*a*b + 3*a + 1)
         """
         try:
             # Compute the single generator, if it exists
@@ -401,7 +401,7 @@ class NumberFieldFractionalIdeal_rel(NumberFieldFractionalIdeal):
             sage: L.<b> = K.extension(5*x^2 + 1)
             sage: P = L.primes_above(2)[0]
             sage: P.relative_norm()
-            Fractional ideal (-6*a + 2)
+            Fractional ideal (6*a + 2)
         """
         L = self.number_field()
         K = L.base_field()
@@ -518,7 +518,7 @@ class NumberFieldFractionalIdeal_rel(NumberFieldFractionalIdeal):
             sage: L.<b> = K.extension(5*x^2 + 1)
             sage: P = L.primes_above(2)[0]
             sage: P.ideal_below()
-            Fractional ideal (-6*a + 2)
+            Fractional ideal (6*a + 2)
         """
         L = self.number_field()
         K = L.base_field()
diff --git a/src/sage/rings/number_field/number_field_rel.py b/src/sage/rings/number_field/number_field_rel.py
index 9e80ef1e3c..dbabb18c50 100644
--- a/src/sage/rings/number_field/number_field_rel.py
+++ b/src/sage/rings/number_field/number_field_rel.py
@@ -217,14 +217,14 @@ class NumberField_relative(NumberField_generic):
             sage: l.<b> = k.extension(5*x^2 + 3); l
             Number Field in b with defining polynomial 5*x^2 + 3 over its base field
             sage: l.pari_rnf()
-            [x^2 + (-1/2*y^2 + y - 3/2)*x + (-1/4*y^3 + 1/4*y^2 - 3/4*y - 13/4), ..., y^4 + 6*y^2 + 1, x^2 + (-1/2*y^2 + y - 3/2)*x + (-1/4*y^3 + 1/4*y^2 - 3/4*y - 13/4)], [0, 0]]
+            [x^2 + (-y^3 + 1/2*y^2 - 6*y + 3/2)*x + (-3/4*y^3 - 1/4*y^2 - 17/4*y - 19/4), ..., y^4 + 6*y^2 + 1, x^2 + (-y^3 + 1/2*y^2 - 6*y + 3/2)*x + (-3/4*y^3 - 1/4*y^2 - 17/4*y - 19/4)], [0, 0]]
             sage: b
             b
 
             sage: l.<b> = k.extension(x^2 + 3/5); l
             Number Field in b with defining polynomial x^2 + 3/5 over its base field
             sage: l.pari_rnf()
-            [x^2 + (-1/2*y^2 + y - 3/2)*x + (-1/4*y^3 + 1/4*y^2 - 3/4*y - 13/4), ..., y^4 + 6*y^2 + 1, x^2 + (-1/2*y^2 + y - 3/2)*x + (-1/4*y^3 + 1/4*y^2 - 3/4*y - 13/4)], [0, 0]]
+            [x^2 + (-y^3 + 1/2*y^2 - 6*y + 3/2)*x + (-3/4*y^3 - 1/4*y^2 - 17/4*y - 19/4), ..., y^4 + 6*y^2 + 1, x^2 + (-y^3 + 1/2*y^2 - 6*y + 3/2)*x + (-3/4*y^3 - 1/4*y^2 - 17/4*y - 19/4)], [0, 0]]
             sage: b
             b
 
diff --git a/src/sage/rings/number_field/order.py b/src/sage/rings/number_field/order.py
index 6eca89ed8d..78ef4c3b33 100644
--- a/src/sage/rings/number_field/order.py
+++ b/src/sage/rings/number_field/order.py
@@ -520,7 +520,7 @@ class Order(IntegralDomain, sage.rings.abc.Order):
             sage: k.<a> = NumberField(x^2 + 5077); G = k.class_group(); G
             Class group of order 22 with structure C22 of Number Field in a with defining polynomial x^2 + 5077
             sage: G.0 ^ -9
-            Fractional ideal class (11, a + 7)
+            Fractional ideal class (43, a + 13)
             sage: Ok = k.maximal_order(); Ok
             Maximal Order in Number Field in a with defining polynomial x^2 + 5077
             sage: Ok * (11, a + 7)
diff --git a/src/sage/rings/number_field/selmer_group.py b/src/sage/rings/number_field/selmer_group.py
index c534aaa9f6..6bc67565d2 100644
--- a/src/sage/rings/number_field/selmer_group.py
+++ b/src/sage/rings/number_field/selmer_group.py
@@ -491,7 +491,7 @@ def pSelmerGroup(K, S, p, proof=None, debug=False):
 
         sage: [K.ideal(g).factor() for g in gens]
         [(Fractional ideal (2, a + 1)) * (Fractional ideal (3, a + 1)),
-        Fractional ideal (-a),
+        Fractional ideal (a),
         (Fractional ideal (2, a + 1))^2,
         1]
 
diff --git a/src/sage/rings/polynomial/polynomial_quotient_ring.py b/src/sage/rings/polynomial/polynomial_quotient_ring.py
index 93e4a74192..8658213658 100644
--- a/src/sage/rings/polynomial/polynomial_quotient_ring.py
+++ b/src/sage/rings/polynomial/polynomial_quotient_ring.py
@@ -1792,7 +1792,7 @@ class PolynomialQuotientRing_generic(CommutativeRing):
             sage: D.selmer_generators([K.ideal(2, -a+1), K.ideal(3, a+1)], 3)
             [2, a + 1]
             sage: D.selmer_generators([K.ideal(2, -a+1), K.ideal(3, a+1), K.ideal(a)], 3)
-            [2, a + 1, a]
+            [2, a + 1, -a]
 
         """
         fields, isos, iso_classes = self._S_decomposition(tuple(S))
diff --git a/src/sage/rings/qqbar.py b/src/sage/rings/qqbar.py
index 7b7c957fdf..0b416aca96 100644
--- a/src/sage/rings/qqbar.py
+++ b/src/sage/rings/qqbar.py
@@ -312,8 +312,8 @@ and we get a way to produce the number directly::
     True
     sage: sage_input(n)
     R.<y> = QQ[]
-    v = AA.polynomial_root(AA.common_polynomial(y^4 - 4*y^2 + 1), RIF(RR(0.51763809020504148), RR(0.51763809020504159)))
-    -109*v^3 - 89*v^2 + 327*v + 178
+    v = AA.polynomial_root(AA.common_polynomial(y^4 - 4*y^2 + 1), RIF(-RR(1.9318516525781366), -RR(1.9318516525781364)))
+    -109*v^3 + 89*v^2 + 327*v - 178
 
 We can also see that some computations (basically, those which are
 easy to perform exactly) are performed directly, instead of storing
@@ -362,7 +362,7 @@ algorithms in :trac:`10255`::
     # Verified
     R1.<x> = QQbar[]
     R2.<y> = QQ[]
-    v = AA.polynomial_root(AA.common_polynomial(y^4 - 4*y^2 + 1), RIF(RR(0.51763809020504148), RR(0.51763809020504159)))
+    v = AA.polynomial_root(AA.common_polynomial(y^4 - 4*y^2 + 1), RIF(-RR(1.9318516525781366), -RR(1.9318516525781364)))
     AA.polynomial_root(AA.common_polynomial(x^4 + QQbar(v^3 - 3*v - 1)*x^3 + QQbar(-v^3 + 3*v - 3)*x^2 + QQbar(-3*v^3 + 9*v + 3)*x + QQbar(3*v^3 - 9*v)), RIF(RR(0.99999999999999989), RR(1.0000000000000002)))
     sage: one
     1
@@ -2310,7 +2310,7 @@ def do_polred(poly, threshold=32):
     cost = 2 * bitsize.nbits() + 5 * poly.degree().nbits()
     if cost > threshold:
         return parent.gen(), parent.gen(), poly
-    new_poly, elt_back = poly.__pari__().polredbest(flag=1)
+    new_poly, elt_back = poly.numerator().__pari__().polredbest(flag=1)
     elt_fwd = elt_back.modreverse()
     return parent(elt_fwd.lift()), parent(elt_back.lift()), parent(new_poly)
 
@@ -2542,10 +2542,10 @@ def number_field_elements_from_algebraics(numbers, minimal=False, same_field=Fal
            Defn: a |--> 1.414213562373095?)
 
         sage: number_field_elements_from_algebraics((rt2,rt3))
-        (Number Field in a with defining polynomial y^4 - 4*y^2 + 1, [-a^3 + 3*a, -a^2 + 2], Ring morphism:
+        (Number Field in a with defining polynomial y^4 - 4*y^2 + 1, [-a^3 + 3*a, a^2 - 2], Ring morphism:
             From: Number Field in a with defining polynomial y^4 - 4*y^2 + 1
             To:   Algebraic Real Field
-            Defn: a |--> 0.5176380902050415?)
+            Defn: a |--> -1.931851652578137?)
 
     ``rt3a`` is a real number in ``QQbar``.  Ordinarily, we'd get a homomorphism
     to ``AA`` (because all elements are real), but if we specify ``same_field=True``,
@@ -2570,7 +2570,7 @@ def number_field_elements_from_algebraics(numbers, minimal=False, same_field=Fal
         (Number Field in a with defining polynomial y^4 - 4*y^2 + 1, -a^3 + 3*a, Ring morphism:
             From: Number Field in a with defining polynomial y^4 - 4*y^2 + 1
             To:   Algebraic Real Field
-            Defn: a |--> 0.5176380902050415?)
+            Defn: a |--> -1.931851652578137?)
 
     We can specify ``minimal=True`` if we want the smallest number field::
 
@@ -2618,7 +2618,7 @@ def number_field_elements_from_algebraics(numbers, minimal=False, same_field=Fal
         sage: nfI^2
         -1
         sage: sum = nfrt2 + nfrt3 + nfI + nfz3; sum
-        2*a^6 + a^5 - a^4 - a^3 - 2*a^2 - a
+        a^5 + a^4 - a^3 + 2*a^2 - a - 1
         sage: hom(sum)
         2.646264369941973? + 1.866025403784439?*I
         sage: hom(sum) == rt2 + rt3 + qqI + z3
@@ -2658,7 +2658,7 @@ def number_field_elements_from_algebraics(numbers, minimal=False, same_field=Fal
         sage: nf, nums, hom = number_field_elements_from_algebraics(elems, embedded=True)
         sage: nf
         Number Field in a with defining polynomial y^24 - 6*y^23 ...- 9*y^2 + 1
-          with a = 0.2598678911433438? + 0.0572892247058457?*I
+          with a = 0.2598679? + 0.0572892?*I
         sage: list(map(QQbar, nums)) == elems == list(map(hom, nums))
         True
 
@@ -2725,7 +2725,7 @@ def number_field_elements_from_algebraics(numbers, minimal=False, same_field=Fal
                          sqrt(2), AA.polynomial_root(x^3-3, RIF(0,3)), 11/9, 1]
         sage: res = number_field_elements_from_algebraics(my_nums, embedded=True)
         sage: res[0]
-        Number Field in a with defining polynomial y^24 - 107010*y^22 - 24*y^21 + ... + 250678447193040618624307096815048024318853254384 with a = -95.5053039433554?
+        Number Field in a with defining polynomial y^24 - 107010*y^22 - 24*y^21 + ... + 250678447193040618624307096815048024318853254384 with a = 93.32530798172420?
     """
     gen = qq_generator
 
@@ -3129,7 +3129,7 @@ class AlgebraicGenerator(SageObject):
             sage: root = ANRoot(x^2 - x - 1, RIF(1, 2))
             sage: gen = AlgebraicGenerator(nf, root)
             sage: gen.pari_field()
-             [y^2 - y - 1, [2, 0], ...]
+            [[y^2 - y - 1, [2, 0], ...]
         """
         if self.is_trivial():
             raise ValueError("No PARI field attached to trivial generator")
@@ -3213,7 +3213,7 @@ class AlgebraicGenerator(SageObject):
             sage: qq_generator.union(gen3) is gen3
             True
             sage: gen2.union(gen3)
-            Number Field in a with defining polynomial y^4 - 4*y^2 + 1 with a in 0.5176380902050415?
+            Number Field in a with defining polynomial y^4 - 4*y^2 + 1 with a in -1.931851652578137?
         """
         if self._trivial:
             return other
@@ -3306,13 +3306,13 @@ class AlgebraicGenerator(SageObject):
             Number Field in a with defining polynomial y^2 - 3 with a in 1.732050807568878?
             sage: gen2_3 = gen2.union(gen3)
             sage: gen2_3
-            Number Field in a with defining polynomial y^4 - 4*y^2 + 1 with a in 0.5176380902050415?
+            Number Field in a with defining polynomial y^4 - 4*y^2 + 1 with a in -1.931851652578137?
             sage: qq_generator.super_poly(gen2) is None
             True
             sage: gen2.super_poly(gen2_3)
             -a^3 + 3*a
             sage: gen3.super_poly(gen2_3)
-            -a^2 + 2
+            a^2 - 2
 
         """
         if checked is None:
@@ -3360,13 +3360,13 @@ class AlgebraicGenerator(SageObject):
             sage: sqrt3 = ANExtensionElement(gen3, nf3.gen())
             sage: gen2_3 = gen2.union(gen3)
             sage: gen2_3
-            Number Field in a with defining polynomial y^4 - 4*y^2 + 1 with a in 0.5176380902050415?
+            Number Field in a with defining polynomial y^4 - 4*y^2 + 1 with a in -1.931851652578137?
             sage: gen2_3(sqrt2)
             -a^3 + 3*a
             sage: gen2_3(ANRational(1/7))
             1/7
             sage: gen2_3(sqrt3)
-            -a^2 + 2
+            a^2 - 2
         """
         if self._trivial:
             return elt._value
@@ -4336,10 +4336,10 @@ class AlgebraicNumber_base(sage.structure.element.FieldElement):
             sage: rt3 = AA(sqrt(3))
             sage: rt3b = rt2 + rt3 - rt2
             sage: rt3b.as_number_field_element()
-            (Number Field in a with defining polynomial y^4 - 4*y^2 + 1, -a^2 + 2, Ring morphism:
+            (Number Field in a with defining polynomial y^4 - 4*y^2 + 1, a^2 - 2, Ring morphism:
                 From: Number Field in a with defining polynomial y^4 - 4*y^2 + 1
                 To:   Algebraic Real Field
-                Defn: a |--> 0.5176380902050415?)
+                Defn: a |--> -1.931851652578137?)
             sage: rt3b.as_number_field_element(minimal=True)
             (Number Field in a with defining polynomial y^2 - 3, a, Ring morphism:
                From: Number Field in a with defining polynomial y^2 - 3
@@ -4401,7 +4401,7 @@ class AlgebraicNumber_base(sage.structure.element.FieldElement):
             sage: rt2b = rt3 + rt2 - rt3
             sage: rt2b.exactify()
             sage: rt2b._exact_value()
-            a^3 - 3*a where a^4 - 4*a^2 + 1 = 0 and a in 1.931851652578137?
+            a^3 - 3*a where a^4 - 4*a^2 + 1 = 0 and a in -0.5176380902050415?
             sage: rt2b.simplify()
             sage: rt2b._exact_value()
             a where a^2 - 2 = 0 and a in 1.414213562373095?
@@ -4422,7 +4422,7 @@ class AlgebraicNumber_base(sage.structure.element.FieldElement):
             sage: QQbar(2)._exact_field()
             Trivial generator
             sage: (sqrt(QQbar(2)) + sqrt(QQbar(19)))._exact_field()
-            Number Field in a with defining polynomial y^4 - 20*y^2 + 81 with a in 2.375100220297941?
+            Number Field in a with defining polynomial y^4 - 20*y^2 + 81 with a in -3.789313782671036?
             sage: (QQbar(7)^(3/5))._exact_field()
             Number Field in a with defining polynomial y^5 - 2*y^4 - 18*y^3 + 38*y^2 + 82*y - 181 with a in 2.554256611698490?
         """
@@ -4442,7 +4442,7 @@ class AlgebraicNumber_base(sage.structure.element.FieldElement):
             sage: QQbar(2)._exact_value()
             2
             sage: (sqrt(QQbar(2)) + sqrt(QQbar(19)))._exact_value()
-            -1/9*a^3 - a^2 + 11/9*a + 10 where a^4 - 20*a^2 + 81 = 0 and a in 2.375100220297941?
+            -1/9*a^3 + a^2 + 11/9*a - 10 where a^4 - 20*a^2 + 81 = 0 and a in -3.789313782671036?
             sage: (QQbar(7)^(3/5))._exact_value()
             2*a^4 + 2*a^3 - 34*a^2 - 17*a + 150 where a^5 - 2*a^4 - 18*a^3 + 38*a^2 + 82*a - 181 = 0 and a in 2.554256611698490?
         """
@@ -6885,7 +6885,7 @@ class AlgebraicPolynomialTracker(SageObject):
             sage: p = sqrt(AA(2)) * x^2 - sqrt(AA(3))
             sage: cp = AA.common_polynomial(p)
             sage: cp.generator()
-            Number Field in a with defining polynomial y^4 - 4*y^2 + 1 with a in 1.931851652578137?
+            Number Field in a with defining polynomial y^4 - 4*y^2 + 1 with a in -0.5176380902050415?
         """
         self.exactify()
         return self._gen
@@ -7734,7 +7734,7 @@ class ANExtensionElement(ANDescr):
 
             sage: rt2b.exactify()
             sage: rt2b._descr
-            a^3 - 3*a where a^4 - 4*a^2 + 1 = 0 and a in 1.931851652578137?
+            a^3 - 3*a where a^4 - 4*a^2 + 1 = 0 and a in -0.5176380902050415?
             sage: rt2b._descr.is_simple()
             False
         """
@@ -7819,7 +7819,7 @@ class ANExtensionElement(ANDescr):
             sage: rt2b = rt3 + rt2 - rt3
             sage: rt2b.exactify()
             sage: rt2b._descr
-            a^3 - 3*a where a^4 - 4*a^2 + 1 = 0 and a in 1.931851652578137?
+            a^3 - 3*a where a^4 - 4*a^2 + 1 = 0 and a in -0.5176380902050415?
             sage: rt2b._descr.simplify(rt2b)
             a where a^2 - 2 = 0 and a in 1.414213562373095?
         """
@@ -7858,9 +7858,9 @@ class ANExtensionElement(ANDescr):
             sage: type(b)
             <class 'sage.rings.qqbar.ANExtensionElement'>
             sage: b.neg(a)
-            1/3*a^3 - 2/3*a^2 + 4/3*a - 2 where a^4 - 2*a^3 + a^2 - 6*a + 9 = 0 and a in -0.7247448713915890? - 1.573132184970987?*I
+            -1/3*a^3 + 1/3*a^2 - a - 1 where a^4 - 2*a^3 + a^2 + 6*a + 3 = 0 and a in 1.724744871391589? + 1.573132184970987?*I
             sage: b.neg("ham spam and eggs")
-            1/3*a^3 - 2/3*a^2 + 4/3*a - 2 where a^4 - 2*a^3 + a^2 - 6*a + 9 = 0 and a in -0.7247448713915890? - 1.573132184970987?*I
+            -1/3*a^3 + 1/3*a^2 - a - 1 where a^4 - 2*a^3 + a^2 + 6*a + 3 = 0 and a in 1.724744871391589? + 1.573132184970987?*I
         """
         return ANExtensionElement(self._generator, -self._value)
 
@@ -7876,9 +7876,9 @@ class ANExtensionElement(ANDescr):
             sage: type(b)
             <class 'sage.rings.qqbar.ANExtensionElement'>
             sage: b.invert(a)
-            7/3*a^3 - 2/3*a^2 + 4/3*a - 12 where a^4 - 2*a^3 + a^2 - 6*a + 9 = 0 and a in -0.7247448713915890? - 1.573132184970987?*I
+            -7/3*a^3 + 19/3*a^2 - 7*a - 9 where a^4 - 2*a^3 + a^2 + 6*a + 3 = 0 and a in 1.724744871391589? + 1.573132184970987?*I
             sage: b.invert("ham spam and eggs")
-            7/3*a^3 - 2/3*a^2 + 4/3*a - 12 where a^4 - 2*a^3 + a^2 - 6*a + 9 = 0 and a in -0.7247448713915890? - 1.573132184970987?*I
+            -7/3*a^3 + 19/3*a^2 - 7*a - 9 where a^4 - 2*a^3 + a^2 + 6*a + 3 = 0 and a in 1.724744871391589? + 1.573132184970987?*I
         """
         return ANExtensionElement(self._generator, ~self._value)
 
@@ -7894,9 +7894,9 @@ class ANExtensionElement(ANDescr):
             sage: type(b)
             <class 'sage.rings.qqbar.ANExtensionElement'>
             sage: b.conjugate(a)
-            -1/3*a^3 + 2/3*a^2 - 4/3*a + 2 where a^4 - 2*a^3 + a^2 - 6*a + 9 = 0 and a in -0.7247448713915890? + 1.573132184970987?*I
+            1/3*a^3 - 1/3*a^2 + a + 1 where a^4 - 2*a^3 + a^2 + 6*a + 3 = 0 and a in 1.724744871391589? - 1.573132184970987?*I
             sage: b.conjugate("ham spam and eggs")
-            -1/3*a^3 + 2/3*a^2 - 4/3*a + 2 where a^4 - 2*a^3 + a^2 - 6*a + 9 = 0 and a in -0.7247448713915890? + 1.573132184970987?*I
+            1/3*a^3 - 1/3*a^2 + a + 1 where a^4 - 2*a^3 + a^2 + 6*a + 3 = 0 and a in 1.724744871391589? - 1.573132184970987?*I
         """
         if self._exactly_real:
             return self
@@ -8529,7 +8529,7 @@ def an_binop_expr(a, b, op):
         sage: x = an_binop_expr(a, b, operator.add); x
         <sage.rings.qqbar.ANBinaryExpr object at ...>
         sage: x.exactify()
-        -6/7*a^7 + 2/7*a^6 + 71/7*a^5 - 26/7*a^4 - 125/7*a^3 + 72/7*a^2 + 43/7*a - 47/7 where a^8 - 12*a^6 + 23*a^4 - 12*a^2 + 1 = 0 and a in 3.12580...?
+        6/7*a^7 - 2/7*a^6 - 71/7*a^5 + 26/7*a^4 + 125/7*a^3 - 72/7*a^2 - 43/7*a + 47/7 where a^8 - 12*a^6 + 23*a^4 - 12*a^2 + 1 = 0 and a in -0.3199179336182997?
 
         sage: a = QQbar(sqrt(2)) + QQbar(sqrt(3))
         sage: b = QQbar(sqrt(3)) + QQbar(sqrt(5))
@@ -8538,7 +8538,7 @@ def an_binop_expr(a, b, op):
         sage: x = an_binop_expr(a, b, operator.mul); x
         <sage.rings.qqbar.ANBinaryExpr object at ...>
         sage: x.exactify()
-        2*a^7 - a^6 - 24*a^5 + 12*a^4 + 46*a^3 - 22*a^2 - 22*a + 9 where a^8 - 12*a^6 + 23*a^4 - 12*a^2 + 1 = 0 and a in 3.1258...?
+        2*a^7 - a^6 - 24*a^5 + 12*a^4 + 46*a^3 - 22*a^2 - 22*a + 9 where a^8 - 12*a^6 + 23*a^4 - 12*a^2 + 1 = 0 and a in -0.3199179336182997?
     """
     return ANBinaryExpr(a, b, op)
 
diff --git a/src/sage/schemes/affine/affine_morphism.py b/src/sage/schemes/affine/affine_morphism.py
index 1c4f2dff18..32c2e47e49 100644
--- a/src/sage/schemes/affine/affine_morphism.py
+++ b/src/sage/schemes/affine/affine_morphism.py
@@ -1148,9 +1148,9 @@ class SchemeMorphism_polynomial_affine_space_field(SchemeMorphism_polynomial_aff
             sage: H = End(A)
             sage: f = H([(QQbar(sqrt(2))*x^2 + 1/QQbar(sqrt(3))) / (5*x)])
             sage: f.reduce_base_field()
-            Scheme endomorphism of Affine Space of dimension 1 over Number Field in a with defining polynomial y^4 - 4*y^2 + 1 with a = 1.931851652578137?
+            Scheme endomorphism of Affine Space of dimension 1 over Number Field in a with defining polynomial y^4 - 4*y^2 + 1 with a = ...?
               Defn: Defined on coordinates by sending (x) to
-                    (((a^3 - 3*a)*x^2 + (1/3*a^2 - 2/3))/(5*x))
+                    (((a^3 - 3*a)*x^2 + (-1/3*a^2 + 2/3))/(5*x))
 
         ::
 
diff --git a/src/sage/schemes/elliptic_curves/ell_field.py b/src/sage/schemes/elliptic_curves/ell_field.py
index 6b64df4d07..aaec89ff34 100644
--- a/src/sage/schemes/elliptic_curves/ell_field.py
+++ b/src/sage/schemes/elliptic_curves/ell_field.py
@@ -845,7 +845,7 @@ class EllipticCurve_field(ell_generic.EllipticCurve_generic, ProjectivePlaneCurv
             sage: E = E.base_extend(G).quadratic_twist(c); E
             Elliptic Curve defined by y^2 = x^3 + 5*a0*x^2 + (-200*a0^2)*x + (-42000*a0^2+42000*a0+126000) over Number Field in a0 with defining polynomial x^3 - 3*x^2 + 3*x + 9
             sage: K.<b> = E.division_field(3, simplify_all=True); K
-            Number Field in b with defining polynomial x^12 - 10*x^10 + 55*x^8 - 60*x^6 + 75*x^4 + 1350*x^2 + 2025
+            Number Field in b with defining polynomial x^12 + 5*x^10 + 40*x^8 + 315*x^6 + 750*x^4 + 675*x^2 + 2025
 
         Some higher-degree examples::
 
diff --git a/src/sage/schemes/elliptic_curves/ell_generic.py b/src/sage/schemes/elliptic_curves/ell_generic.py
index 926ae310ea..3bae819fb0 100644
--- a/src/sage/schemes/elliptic_curves/ell_generic.py
+++ b/src/sage/schemes/elliptic_curves/ell_generic.py
@@ -3324,8 +3324,8 @@ class EllipticCurve_generic(WithEqualityById, plane_curve.ProjectivePlaneCurve):
             sage: K.<a> = QuadraticField(2)
             sage: E = EllipticCurve([1,a])
             sage: E.pari_curve()
-            [Mod(0, y^2 - 2), Mod(0, y^2 - 2), Mod(0, y^2 - 2), Mod(1, y^2 - 2),
-            Mod(y, y^2 - 2), Mod(0, y^2 - 2), Mod(2, y^2 - 2), Mod(4*y, y^2 - 2),
+            [0, 0, 0, Mod(1, y^2 - 2),
+            Mod(y, y^2 - 2), 0, Mod(2, y^2 - 2), Mod(4*y, y^2 - 2),
             Mod(-1, y^2 - 2), Mod(-48, y^2 - 2), Mod(-864*y, y^2 - 2),
             Mod(-928, y^2 - 2), Mod(3456/29, y^2 - 2), Vecsmall([5]),
             [[y^2 - 2, [2, 0], 8, 1, [[1, -1.41421356237310;
diff --git a/src/sage/schemes/elliptic_curves/ell_number_field.py b/src/sage/schemes/elliptic_curves/ell_number_field.py
index edbd196090..c44c803aa8 100644
--- a/src/sage/schemes/elliptic_curves/ell_number_field.py
+++ b/src/sage/schemes/elliptic_curves/ell_number_field.py
@@ -218,7 +218,7 @@ class EllipticCurve_number_field(EllipticCurve_field):
             sage: E == loads(dumps(E))
             True
             sage: E.simon_two_descent()
-            (2, 2, [(0 : 0 : 1)])
+            (2, 2, [(0 : 0 : 1), (1/18*a + 7/18 : -5/54*a - 17/54 : 1)])
             sage: E.simon_two_descent(lim1=5, lim3=5, limtriv=10, maxprob=7, limbigprime=10)
             (2, 2, [(-1 : 0 : 1), (-2 : -1/2*a - 1/2 : 1)])
 
@@ -274,7 +274,7 @@ class EllipticCurve_number_field(EllipticCurve_field):
             sage: E.simon_two_descent()  # long time (4s on sage.math, 2013)
             (3,
              3,
-             [(5/8*zeta43_0^2 + 17/8*zeta43_0 - 9/4 : -27/16*zeta43_0^2 - 103/16*zeta43_0 + 39/8 : 1),
+             [(1/8*zeta43_0^2 - 3/8*zeta43_0 - 1/4 : -5/16*zeta43_0^2 + 7/16*zeta43_0 + 1/8 : 1),
               (0 : 0 : 1)])
         """
         verbose = int(verbose)
@@ -865,7 +865,7 @@ class EllipticCurve_number_field(EllipticCurve_field):
             Conductor exponent: 1
             Kodaira Symbol: I1
             Tamagawa Number: 1,
-            Local data at Fractional ideal (-3*i - 2):
+            Local data at Fractional ideal (-2*i + 3):
             Reduction type: bad split multiplicative
             Local minimal model: Elliptic Curve defined by y^2 + (i+1)*x*y + y = x^3 over Number Field in i with defining polynomial x^2 + 1
             Minimal discriminant valuation: 2
@@ -2645,12 +2645,12 @@ class EllipticCurve_number_field(EllipticCurve_field):
             [-92, -23, -23]
 
             sage: C.matrix()  # long time
-            [1 2 2 4 2 4]
-            [2 1 2 2 4 4]
-            [2 2 1 4 4 2]
-            [4 2 4 1 3 3]
-            [2 4 4 3 1 3]
-            [4 4 2 3 3 1]
+            [1 2 2 4 4 2]
+            [2 1 2 4 2 4]
+            [2 2 1 2 4 4]
+            [4 4 2 1 3 3]
+            [4 2 4 3 1 3]
+            [2 4 4 3 3 1]
 
         The graph of this isogeny class has a shape which does not
         occur over `\QQ`: a triangular prism.  Note that for curves
@@ -2677,12 +2677,12 @@ class EllipticCurve_number_field(EllipticCurve_field):
 
             sage: G = C.graph()  # long time
             sage: G.adjacency_matrix()  # long time
-            [0 1 1 0 1 0]
-            [1 0 1 1 0 0]
-            [1 1 0 0 0 1]
-            [0 1 0 0 1 1]
-            [1 0 0 1 0 1]
-            [0 0 1 1 1 0]
+            [0 1 1 0 0 1]
+            [1 0 1 0 1 0]
+            [1 1 0 1 0 0]
+            [0 0 1 0 1 1]
+            [0 1 0 1 0 1]
+            [1 0 0 1 1 0]
 
         To display the graph without any edge labels::
 
@@ -3316,7 +3316,7 @@ class EllipticCurve_number_field(EllipticCurve_field):
             sage: points = [E.lift_x(x) for x in xi]
             sage: newpoints, U = E.lll_reduce(points)  # long time (35s on sage.math, 2011)
             sage: [P[0] for P in newpoints]            # long time
-            [6823803569166584943, 5949539878899294213, 2005024558054813068, 5864879778877955778, 23955263915878682727/4, 5922188321411938518, 5286988283823825378, 175620639884534615751/25, -11451575907286171572, 3502708072571012181, 1500143935183238709184/225, 27180522378120223419/4, -5811874164190604461581/625, 26807786527159569093, 7404442636649562303, 475656155255883588, 265757454726766017891/49, 7272142121019825303, 50628679173833693415/4, 6951643522366348968, 6842515151518070703, 111593750389650846885/16, 2607467890531740394315/9, -1829928525835506297]
+            [6823803569166584943, 5949539878899294213, 2005024558054813068, 5864879778877955778, 23955263915878682727/4, 5922188321411938518, 5286988283823825378, 11465667352242779838, -11451575907286171572, 3502708072571012181, 1500143935183238709184/225, 27180522378120223419/4, -5811874164190604461581/625, 26807786527159569093, 7041412654828066743, 475656155255883588, 265757454726766017891/49, 7272142121019825303, 50628679173833693415/4, 6951643522366348968, 6842515151518070703, 111593750389650846885/16, 2607467890531740394315/9, -1829928525835506297]
 
         An example to show the explicit use of the height pairing matrix::
 
diff --git a/src/sage/schemes/elliptic_curves/ell_rational_field.py b/src/sage/schemes/elliptic_curves/ell_rational_field.py
index fc54013b7b..94143ad2d6 100644
--- a/src/sage/schemes/elliptic_curves/ell_rational_field.py
+++ b/src/sage/schemes/elliptic_curves/ell_rational_field.py
@@ -1827,7 +1827,7 @@ class EllipticCurve_rational_field(EllipticCurve_number_field):
             sage: E = EllipticCurve('389a1')
             sage: E._known_points = []  # clear cached points
             sage: E.simon_two_descent()
-            (2, 2, [(1 : 0 : 1), (-11/9 : 28/27 : 1)])
+            (2, 2, [(5/4 : 5/8 : 1), (-3/4 : 7/8 : 1)])
             sage: E = EllipticCurve('5077a1')
             sage: E.simon_two_descent()
             (3, 3, [(1 : 0 : 1), (2 : 0 : 1), (0 : 2 : 1)])
diff --git a/src/sage/schemes/elliptic_curves/gal_reps_number_field.py b/src/sage/schemes/elliptic_curves/gal_reps_number_field.py
index 81ad295160..d484a4a18b 100644
--- a/src/sage/schemes/elliptic_curves/gal_reps_number_field.py
+++ b/src/sage/schemes/elliptic_curves/gal_reps_number_field.py
@@ -780,12 +780,12 @@ def deg_one_primes_iter(K, principal_only=False):
         [Fractional ideal (2, a + 1),
          Fractional ideal (3, a + 1),
          Fractional ideal (3, a + 2),
-         Fractional ideal (-a),
+         Fractional ideal (a),
          Fractional ideal (7, a + 3),
          Fractional ideal (7, a + 4)]
         sage: it = deg_one_primes_iter(K, True)
         sage: [next(it) for _ in range(6)]
-        [Fractional ideal (-a),
+        [Fractional ideal (a),
          Fractional ideal (-2*a + 3),
          Fractional ideal (2*a + 3),
          Fractional ideal (a + 6),
diff --git a/src/sage/schemes/elliptic_curves/gp_simon.py b/src/sage/schemes/elliptic_curves/gp_simon.py
index 28b97f34af..9f7d1b6020 100644
--- a/src/sage/schemes/elliptic_curves/gp_simon.py
+++ b/src/sage/schemes/elliptic_curves/gp_simon.py
@@ -56,7 +56,7 @@ def simon_two_descent(E, verbose=0, lim1=None, lim3=None, limtriv=None,
         sage: import sage.schemes.elliptic_curves.gp_simon
         sage: E=EllipticCurve('389a1')
         sage: sage.schemes.elliptic_curves.gp_simon.simon_two_descent(E)
-        (2, 2, [(1 : 0 : 1), (-11/9 : 28/27 : 1)])
+        (2, 2, [(5/4 : 5/8 : 1), (-3/4 : 7/8 : 1)])
 
     TESTS::
 
@@ -117,7 +117,7 @@ def simon_two_descent(E, verbose=0, lim1=None, lim3=None, limtriv=None,
     # The block below mimics the defaults in Simon's scripts, and needs to be changed
     # when these are updated.
     if K is QQ:
-        cmd = 'ellrank(%s, %s);' % (list(E.ainvs()), [P.__pari__() for P in known_points])
+        cmd = 'ellQ_ellrank(%s, %s);' % (list(E.ainvs()), [P.__pari__() for P in known_points])
         if lim1 is None:
             lim1 = 5
         if lim3 is None:
@@ -144,7 +144,7 @@ def simon_two_descent(E, verbose=0, lim1=None, lim3=None, limtriv=None,
     if verbose > 0:
         print(s)
     v = gp.eval('ans')
-    if v=='ans': # then the call to ellrank() or bnfellrank() failed
+    if v=='ans': # then the call to ellQ_ellrank() or bnfellrank() failed
         raise RuntimeError("An error occurred while running Simon's 2-descent program")
     if verbose >= 2:
         print("v = %s" % v)
diff --git a/src/sage/schemes/elliptic_curves/isogeny_small_degree.py b/src/sage/schemes/elliptic_curves/isogeny_small_degree.py
index a936deb74f..dc19254d8c 100644
--- a/src/sage/schemes/elliptic_curves/isogeny_small_degree.py
+++ b/src/sage/schemes/elliptic_curves/isogeny_small_degree.py
@@ -1208,14 +1208,14 @@ def isogenies_13_0(E, minimal_models=True):
         sage: [phi.codomain().ainvs() for phi in isogenies_13_0(E)]  # long time (4s)
         [(0,
           0,
-          20360599/165164973653422080*a^11 - 3643073/41291243413355520*a^10 - 101/8789110986240*a^9 + 5557619461/573489491852160*a^8 - 82824971/11947697746920*a^7 - 19487/21127670640*a^6 - 475752603733/29409717530880*a^5 + 87205112531/7352429382720*a^4 + 8349/521670880*a^3 + 5858744881/12764634345*a^2 - 1858703809/2836585410*a + 58759402/48906645,
+          20360599/165164973653422080*a^11 - 3643073/41291243413355520*a^10 + 1887439/1146978983704320*a^9 + 5557619461/573489491852160*a^8 - 82824971/11947697746920*a^7 + 1030632647/7965131831280*a^6 - 475752603733/29409717530880*a^5 + 87205112531/7352429382720*a^4 - 43618899433/204234149520*a^3 + 5858744881/12764634345*a^2 - 1858703809/2836585410*a + 2535050171/1418292705,
           -139861295/2650795873449984*a^11 - 3455957/5664093746688*a^10 - 345310571/50976843720192*a^9 - 500530795/118001953056*a^8 - 12860048113/265504394376*a^7 - 25007420461/44250732396*a^6 + 458134176455/1416023436672*a^5 + 16701880631/9077073312*a^4 + 155941666417/9077073312*a^3 + 3499310115/378211388*a^2 - 736774863/94552847*a - 21954102381/94552847,
-          579363345221/13763747804451840*a^11 + 371192377511/860234237778240*a^10 + 8855090365657/1146978983704320*a^9 + 5367261541663/1633873196160*a^8 + 614883554332193/15930263662560*a^7 + 30485197378483/68078049840*a^6 - 131000897588387/2450809794240*a^5 - 203628705777949/306351224280*a^4 - 1587619388190379/204234149520*a^3 + 14435069706551/11346341640*a^2 + 7537273048614/472764235*a + 89198980034806/472764235),
+          8342795944891/198197968384106496*a^11 + 8908625263589/20645621706677760*a^10 + 53130542636623/6881873902225920*a^9 + 376780111042213/114697898370432*a^8 + 614884052146333/15930263662560*a^7 + 3566768133324359/7965131831280*a^6 - 1885593809102545/35291661037056*a^5 - 2443732172026523/3676214691360*a^4 - 9525729503937541/1225404897120*a^3 + 51990274442321/40846829904*a^2 + 67834019370596/4254878115*a + 267603083706812/1418292705),
          (0,
           0,
-          20360599/165164973653422080*a^11 - 3643073/41291243413355520*a^10 - 101/8789110986240*a^9 + 5557619461/573489491852160*a^8 - 82824971/11947697746920*a^7 - 19487/21127670640*a^6 - 475752603733/29409717530880*a^5 + 87205112531/7352429382720*a^4 + 8349/521670880*a^3 + 5858744881/12764634345*a^2 - 1858703809/2836585410*a + 58759402/48906645,
+          20360599/165164973653422080*a^11 - 3643073/41291243413355520*a^10 + 1887439/1146978983704320*a^9 + 5557619461/573489491852160*a^8 - 82824971/11947697746920*a^7 + 1030632647/7965131831280*a^6 - 475752603733/29409717530880*a^5 + 87205112531/7352429382720*a^4 - 43618899433/204234149520*a^3 + 5858744881/12764634345*a^2 - 1858703809/2836585410*a + 2535050171/1418292705,
           -6465569317/1325397936724992*a^11 - 112132307/1960647835392*a^10 - 17075412917/25488421860096*a^9 - 207832519229/531008788752*a^8 - 1218275067617/265504394376*a^7 - 9513766502551/177002929584*a^6 + 4297077855437/708011718336*a^5 + 354485975837/4538536656*a^4 + 4199379308059/4538536656*a^3 - 30841577919/189105694*a^2 - 181916484042/94552847*a - 2135779171614/94552847,
-          -132601797212627/3440936951112960*a^11 - 6212467020502021/13763747804451840*a^10 - 1515926454902497/286744745926080*a^9 - 15154913741799637/4901619588480*a^8 - 576888119803859263/15930263662560*a^7 - 86626751639648671/204234149520*a^6 + 16436657569218427/306351224280*a^5 + 1540027900265659087/2450809794240*a^4 + 375782662805915809/51058537380*a^3 - 14831920924677883/11346341640*a^2 - 7237947774817724/472764235*a - 84773764066089509/472764235)]
+          -1316873026840277/34172063514501120*a^11 - 18637401045099413/41291243413355520*a^10 - 36382234917217247/6881873902225920*a^9 - 61142238484016213/19775499719040*a^8 - 576888119306045123/15930263662560*a^7 - 3378443313906256321/7965131831280*a^6 + 326466167429333279/6084769144320*a^5 + 4620083325391594991/7352429382720*a^4 + 9018783894167184149/1225404897120*a^3 - 9206015742300283/7042556880*a^2 - 65141531411426446/4254878115*a - 254321286054666133/1418292705)]
     """
     if E.j_invariant()!=0:
         raise ValueError("j-invariant must be 0.")

A sagemath-git/sagemath-tachyon-0.99.patch => sagemath-git/sagemath-tachyon-0.99.patch +78 -0
@@ 0,0 1,78 @@
--- a/src/sage/interfaces/tachyon.py
+++ b/src/sage/interfaces/tachyon.py
@@ -140,14 +140,14 @@ written in the sequence they are listed in the examples in this section.
 The ``PROJECTION`` keyword must be followed by one of the supported
 camera projection mode identifiers ``PERSPECTIVE``, ``PERSPECTIVE_DOF``,
 ``ORTHOGRAPHIC``, or ``FISHEYE``. The ``FISHEYE`` projection mode
-requires two extra parameters ``FOCALLENGTH`` and ``APERTURE`` which
+requires two extra parameters ``FOCALDIST`` and ``APERTURE`` which
 precede the regular camera options.
 
 ::
 
    Camera
      projection perspective_dof
-     focallength 0.75
+     FOCALDIST 0.75
      aperture 0.02
      Zoom 0.666667
      Aspectratio 1.000000
--- a/src/sage/plot/plot3d/tachyon.py
+++ b/src/sage/plot/plot3d/tachyon.py
@@ -92,7 +92,7 @@ angle, right angle)::
 Finally there is the ``projection='perspective_dof'`` option. ::
 
     sage: T = Tachyon(xres=800, antialiasing=4, raydepth=10,
-    ....: projection='perspective_dof', focallength='1.0', aperture='.0025')
+    ....: projection='perspective_dof', FOCALDIST='1.0', aperture='.0025')
     sage: T.light((0,5,7), 1.0, (1,1,1))
     sage: T.texture('t1', opacity=1, specular=.3)
     sage: T.texture('t2', opacity=1, specular=.3, color=(0,0,1))
@@ -186,7 +186,7 @@ class Tachyon(WithEqualityById, SageObject):
       or ``'fisheye'``.
     - ``frustum`` - (default ''), otherwise list of four numbers. Only
       used with projection='fisheye'.
-    - ``focallength`` - (default ''), otherwise a number. Only used
+    - ``FOCALDIST`` - (default ''), otherwise a number. Only used
       with projection='perspective_dof'.
     - ``aperture`` - (default ''), otherwise a number.  Only used
       with projection='perspective_dof'.
@@ -331,7 +331,7 @@ class Tachyon(WithEqualityById, SageObject):
     Use of the ``projection='perspective_dof'`` option.  This may not be
     implemented correctly. ::
 
-        sage: T = Tachyon(xres=800,antialiasing=4, raydepth=10, projection='perspective_dof', focallength='1.0', aperture='.0025')
+        sage: T = Tachyon(xres=800,antialiasing=4, raydepth=10, projection='perspective_dof', FOCALDIST='1.0', aperture='.0025')
         sage: T.light((0,5,7), 1.0, (1,1,1))
         sage: T.texture('t1', opacity=1, specular=.3)
         sage: T.texture('t2', opacity=1, specular=.3, color=(0,0,1))
@@ -365,7 +365,7 @@ class Tachyon(WithEqualityById, SageObject):
                  look_at=[0, 0, 0],
                  viewdir=None,
                  projection='PERSPECTIVE',
-                 focallength='',
+                 FOCALDIST='',
                  aperture='',
                  frustum=''):
         r"""
@@ -391,7 +391,7 @@ class Tachyon(WithEqualityById, SageObject):
             self._camera_position = (-3, 0, 0) # default value
         self._updir = updir
         self._projection = projection
-        self._focallength = focallength
+        self._FOCALDIST = FOCALDIST
         self._aperture = aperture
         self._frustum = frustum
         self._objects = []
@@ -624,9 +624,9 @@ class Tachyon(WithEqualityById, SageObject):
         camera_out = r"""
            camera
               projection %s""" % (tostr(self._projection))
-        if self._focallength != '':
+        if self._FOCALDIST != '':
             camera_out = camera_out + r"""
-              focallength %s""" % (float(self._focallength))
+              FOCALDIST %s""" % (float(self._FOCALDIST))
         if self._aperture != '':
             camera_out = camera_out + r"""
               aperture %s""" % (float(self._aperture))

A sagemath-git/sagemath-tdlib-0.9.patch => sagemath-git/sagemath-tdlib-0.9.patch +28 -0
@@ 0,0 1,28 @@
diff -up src/sage/graphs/graph_decompositions/sage_tdlib.cpp.orig src/sage/graphs/graph_decompositions/sage_tdlib.cpp
--- a/src/sage/graphs/graph_decompositions/sage_tdlib.cpp	2021-05-09 16:00:11.000000000 -0600
+++ b/src/sage/graphs/graph_decompositions/sage_tdlib.cpp	2021-06-16 08:33:47.325415307 -0600
@@ -2,8 +2,8 @@
 #include <map>
 
 #include <boost/graph/adjacency_list.hpp>
-#include "tdlib/TD_combinations.hpp"
-#include "tdlib/TD_misc.hpp"
+#include <treedec/combinations.hpp>
+#include <treedec/misc.hpp>
 
 #ifndef TD_STRUCT_VERTEX
 #define TD_STRUCT_VERTEX
@@ -16,13 +16,6 @@ struct Vertex{
 
 typedef boost::adjacency_list<boost::setS, boost::vecS, boost::undirectedS, Vertex> TD_graph_t;
 
-struct bag{
-    std::set<unsigned int> bag;
-};
-
-typedef boost::adjacency_list<boost::vecS, boost::vecS, boost::undirectedS, bag> TD_tree_dec_t;
-
-
 void make_tdlib_graph(TD_graph_t &G, std::vector<unsigned int> &V, std::vector<unsigned int> &E){
     unsigned int max = 0;
     for(unsigned int i = 0; i < V.size(); i++)

A sagemath-git/test-optional.patch => sagemath-git/test-optional.patch +17 -0
@@ 0,0 1,17 @@
diff --git a/src/sage/doctest/control.py b/src/sage/doctest/control.py
index 2d93841e50..937e20cd2e 100644
--- a/src/sage/doctest/control.py
+++ b/src/sage/doctest/control.py
@@ -400,11 +400,6 @@ class DocTestController(SageObject):
                 # that the package is actually installed).
                 if 'optional' in options.optional:
                     options.optional.discard('optional')
-                    from sage.misc.package import list_packages
-                    for pkg in list_packages('optional', local=True).values():
-                        if pkg.is_installed() and pkg.installed_version == pkg.remote_version:
-                            options.optional.add(pkg.name)
-
                     from sage.features import package_systems
                     options.optional.update(system.name