diff --git a/srcpkgs/sagemath/patches/trac-31355-upgrade_lrcalc_to_2.1.patch b/srcpkgs/sagemath/patches/trac-31355-upgrade_lrcalc_to_2.1.patch
new file mode 100644
index 0000000000..4bd6f4f4e2
--- /dev/null
+++ b/srcpkgs/sagemath/patches/trac-31355-upgrade_lrcalc_to_2.1.patch
@@ -0,0 +1,670 @@
+As produced by `git diff 9.5 9.6.beta3 -- src/sage/libs/lrcalc`
+
+diff --git a/src/sage/libs/lrcalc/lrcalc.pxd b/src/sage/libs/lrcalc/lrcalc.pxd
+deleted file mode 100644
+index 10b88db93f2..00000000000
+--- a/src/sage/libs/lrcalc/lrcalc.pxd
++++ /dev/null
+@@ -1,77 +0,0 @@
+-# distutils: libraries = lrcalc
+-
+-cdef extern from "lrcalc/hashtab.h":
+- ctypedef struct hashtab:
+- pass
+-
+- ctypedef struct hash_itr:
+- pass
+-
+- ctypedef unsigned long hashkey_t
+- ctypedef int (*cmp_t) (void* a, void* b)
+- ctypedef hashkey_t (*hash_t) (void* a)
+-
+- hashtab* hash_new(cmp_t cm, hash_t hsh)
+- void hash_free(hashtab *ht)
+-
+- void* hash_lookup(hashtab *ht, void *key)
+- void* hash_insert(hashtab *ht, void *key, void *value)
+-
+- bint hash_good(hash_itr)
+- void hash_first(hashtab* s, hash_itr itr)
+- void hash_next(hash_itr itr)
+- void* hash_key(hash_itr itr)
+- void* hash_value(hash_itr itr)
+- int hash_intvalue(hash_itr itr)
+-
+-cdef extern from "lrcalc/vector.h":
+- ctypedef struct vector:
+- size_t length
+- int* array
+-
+- vector* v_new(int length)
+- void v_free(vector* v)
+- void v_print(vector *v)
+- int v_length(vector* v)
+- int v_elem(vector* v, int i)
+-
+- ctypedef struct vecpair:
+- vector *first
+- vector *second
+-
+- vector* vp_first(vecpair* vp)
+- vector* vp_second(vecpair* vp)
+-
+-cdef extern from "lrcalc/list.h":
+- cdef struct _list:
+- void **array
+- size_t allocated
+- size_t length
+- void l_free(_list *lst)
+-
+-cdef extern from "lrcalc/symfcn.h":
+- long long lrcoef_c "lrcoef"(vector* outer, vector* inner1, vector* inner2)
+- hashtab* mult_c "mult"(vector *sh1, vector *sh2, int maxrows)
+- hashtab* skew_c "skew"(vector *outer, vector *inner, int maxrows)
+- hashtab* coprod_c "coprod"(vector *part, int all)
+- void fusion_reduce_c "fusion_reduce"(hashtab* ht, int rows, int cols, int opt_zero)
+- _list *quantum_reduce_c "quantum_reduce"(hashtab* ht, int rows, int col)
+-
+- ctypedef struct skewtab:
+- vector *outer
+- vector *inner
+- vector *conts
+- int maxrows
+- vector *conjugate
+- int rows
+- int cols
+- int matrix[1]
+-
+- skewtab *st_new(vector *outer, vector *inner, vector *conts, int maxrows)
+- int st_next(skewtab *st)
+- void st_print(skewtab *st)
+- void st_free(skewtab *st)
+-
+-
+-cdef extern from "lrcalc/schublib.h":
+- hashtab* mult_schubert_c "mult_schubert"(vector *sh1, vector *sh2, int rank)
+diff --git a/src/sage/libs/lrcalc/lrcalc.pyx b/src/sage/libs/lrcalc/lrcalc.py
+similarity index 60%
+rename from src/sage/libs/lrcalc/lrcalc.pyx
+rename to src/sage/libs/lrcalc/lrcalc.py
+index b591081ec4c..b541bfacd89 100644
+--- a/src/sage/libs/lrcalc/lrcalc.pyx
++++ b/src/sage/libs/lrcalc/lrcalc.py
+@@ -10,7 +10,8 @@ fusion products. All of the above are achieved by counting LR
+ appropriate shape and content by iterating through them.
+ Additionally, ``lrcalc`` handles products of Schubert polynomials.
+
+-The web page of ``lrcalc`` is ``_.
++The web page of ``lrcalc`` is
++``_.
+
+ The following describes the Sage interface to this library.
+
+@@ -36,12 +37,13 @@ Schur expansion::
+ [4, 2]: 1}
+
+ Same product, but include only partitions with at most 3 rows. This
+-corresponds to computing in the representation ring of gl(3)::
++corresponds to computing in the representation ring of `\mathfrak{gl}(3)`::
+
+ sage: lrcalc.mult([2,1], [2,1], 3)
+ {[2, 2, 2]: 1, [3, 2, 1]: 2, [3, 3]: 1, [4, 1, 1]: 1, [4, 2]: 1}
+
+-We can also compute the fusion product, here for sl(3) and level 2::
++We can also compute the fusion product, here for `\mathfrak{sl}(3)`
++and level 2::
+
+ sage: lrcalc.mult([3,2,1], [3,2,1], 3,2)
+ {[4, 4, 4]: 1, [5, 4, 3]: 1}
+@@ -77,42 +79,38 @@ Multiply two Schubert polynomials::
+ [6, 2, 1, 4, 3, 5]: 1}
+
+ Same product, but include only permutations of 5 elements in the result.
+-This corresponds to computing in the cohomology ring of Fl(5)::
++This corresponds to computing in the cohomology ring of `Fl(5)`::
+
+ sage: lrcalc.mult_schubert([4,2,1,3], [1,4,2,5,3], 5)
+ {[4, 5, 1, 3, 2]: 1, [5, 3, 1, 4, 2]: 1, [5, 4, 1, 2, 3]: 1}
+
+ List all Littlewood-Richardson tableaux of skew shape `\mu/\nu`; in
+ this example `\mu=[3,2,1]` and `\nu=[2,1]`. Specifying a third entry
+-`maxrows` restricts the alphabet to `\{1,2,\ldots,maxrows\}`::
++`M' = ``maxrows`` restricts the alphabet to `\{1,2,\ldots,M\}`::
+
+ sage: list(lrcalc.lrskew([3,2,1],[2,1]))
+ [[[None, None, 1], [None, 1], [1]], [[None, None, 1], [None, 1], [2]],
+ [[None, None, 1], [None, 2], [1]], [[None, None, 1], [None, 2], [3]]]
+
+ sage: list(lrcalc.lrskew([3,2,1],[2,1],maxrows=2))
+- [[[None, None, 1], [None, 1], [1]], [[None, None, 1], [None, 1], [2]], [[None, None, 1], [None, 2], [1]]]
++ [[[None, None, 1], [None, 1], [1]], [[None, None, 1], [None, 1], [2]],
++ [[None, None, 1], [None, 2], [1]]]
+
+ .. TODO::
+
+- use this library in the :class:`SymmetricFunctions` code, to
++ Use this library in the :class:`SymmetricFunctions` code, to
+ make it easy to apply it to linear combinations of Schur functions.
+
+ .. SEEALSO::
+
+ - :func:`lrcoef`
+-
+ - :func:`mult`
+-
+ - :func:`coprod`
+-
+ - :func:`skew`
+-
+ - :func:`lrskew`
+-
+ - :func:`mult_schubert`
+
+-.. rubric:: Underlying algorithmic in lrcalc
++.. RUBRIC:: Underlying algorithmic in lrcalc
+
+ Here is some additional information regarding the main low-level
+ C-functions in `lrcalc`. Given two partitions ``outer`` and ``inner``
+@@ -187,180 +185,24 @@ AUTHORS:
+ # https://www.gnu.org/licenses/
+ # ****************************************************************************
+
+-from sage.rings.integer cimport Integer
+-from sage.structure.parent cimport Parent
+ from sage.combinat.partition import _Partitions
+ from sage.combinat.permutation import Permutation
+-from sage.combinat.skew_tableau import SkewTableau
+-
+-
+-cdef vector* iterable_to_vector(it):
+- """
+- Return an lrcalc vector (which is a list of integers) from a Python iterable.
+-
+- TESTS::
+-
+- sage: from sage.libs.lrcalc.lrcalc import test_iterable_to_vector
+- sage: x = test_iterable_to_vector(Partition([3,2,1])); x #indirect doctest
+- [3, 2, 1]
+- """
+- cdef vector* v
+- cdef list itr = list(it)
+- cdef int n = len(itr)
+- cdef int i
+- v = v_new(n)
+- for i in range(n):
+- v.array[i] = int(itr[i])
+- return v
+-
+-
+-cdef list vector_to_list(vector *v):
+- """
+- Converts a lrcalc vector to Python list.
+-
+- TESTS::
+-
+- sage: from sage.libs.lrcalc.lrcalc import test_iterable_to_vector
+- sage: x = test_iterable_to_vector([]); x #indirect doctest
+- []
+- """
+- cdef int i, n
+- n = v_length(v)
+- cdef list result = [None]*n
+- for i in range(n):
+- result[i] = Integer(v_elem(v, i))
+- return result
+-
+-
+-def test_iterable_to_vector(it):
+- """
+- A wrapper function for the cdef function ``iterable_to_vector``
+- and ``vector_to_list``, to test that they are working correctly.
++from sage.combinat.skew_tableau import SemistandardSkewTableaux
++from sage.combinat.skew_partition import SkewPartition
++from sage.rings.integer import Integer
++import lrcalc
+
+- EXAMPLES::
+-
+- sage: from sage.libs.lrcalc.lrcalc import test_iterable_to_vector
+- sage: x = test_iterable_to_vector([3,2,1]); x
+- [3, 2, 1]
+- """
+- cdef vector *v = iterable_to_vector(it)
+- result = vector_to_list(v)
+- v_free(v)
+- return result
+-
+-
+-cdef skewtab_to_SkewTableau(skewtab *st):
+- """
+- A wrapper function which transforms the data set ``st`` used in
+- ``lrcalc`` to a ``SkewTableau`` in Sage.
++def _lrcalc_dict_to_sage(result):
++ r"""
++ Translate from lrcalc output format to Sage expected format.
+
+ TESTS::
+
+- sage: from sage.libs.lrcalc.lrcalc import test_skewtab_to_SkewTableau
+- sage: test_skewtab_to_SkewTableau([],[])
+- []
+- """
+- inner = vector_to_list(st.inner)
+- outer = vector_to_list(st.outer)
+- return SkewTableau(expr=[[inner[y] for y in range(len(outer))],
+- [[st.matrix[x + y * st.cols] + 1
+- for x in range(inner[y], outer[y])]
+- for y in range(len(outer) - 1, -1, -1)]])
+-
+-
+-def test_skewtab_to_SkewTableau(outer, inner):
+- """
+- A wrapper function for the cdef function ``skewtab_to_SkewTableau``
+- for testing purposes.
+-
+- It constructs the first LR skew tableau of shape ``outer/inner``
+- as an ``lrcalc`` ``skewtab``, and converts it to a
+- :class:`SkewTableau`.
+-
+- EXAMPLES::
+-
+- sage: from sage.libs.lrcalc.lrcalc import test_skewtab_to_SkewTableau
+- sage: test_skewtab_to_SkewTableau([3,2,1],[])
+- [[1, 1, 1], [2, 2], [3]]
+- sage: test_skewtab_to_SkewTableau([4,3,2,1],[1,1]).pp()
+- . 1 1 1
+- . 2 2
+- 1 3
+- 2
+- """
+- cdef vector* o = iterable_to_vector(outer)
+- cdef vector* i = iterable_to_vector(inner+[0]*(len(outer)-len(inner)))
+- cdef skewtab* st = st_new(o, i, NULL, 0)
+- return skewtab_to_SkewTableau(st)
+-
+-
+-cdef dict sf_hashtab_to_dict(hashtab *ht):
+- """
+- Return a dictionary representing a Schur function. The keys are
+- partitions and the values are integers .
+-
+- EXAMPLES::
+-
+ sage: from sage.libs.lrcalc.lrcalc import mult
+- sage: sorted(mult([1],[1]).items()) #indirect doctest
+- [([1, 1], 1), ([2], 1)]
+- sage: assert isinstance(mult([1],[1]),dict)#indirect doctest
+- """
+- cdef hash_itr itr
+- cdef dict result = {}
+- cdef list p
+- hash_first(ht, itr)
+- while hash_good(itr):
+- p = vector_to_list( hash_key(itr))
+- result[_Partitions(p)] = Integer(hash_intvalue(itr))
+- hash_next(itr)
+- return result
+-
+-
+-cdef dict schubert_hashtab_to_dict(hashtab *ht):
+- """
+- Return a dictionary corresponding to a Schubert polynomial whose keys
+- are permutations and whose values are integers .
+-
+- EXAMPLES::
+-
+- sage: from sage.libs.lrcalc.lrcalc import mult_schubert
+- sage: mult_schubert([3,2,1], [1,2,3]) #indirect doctest
+- {[3, 2, 1]: 1}
+- """
+- cdef hash_itr itr
+- cdef dict result = {}
+- hash_first(ht, itr)
+- while hash_good(itr):
+- p = vector_to_list( hash_key(itr))
+- result[Permutation(p)] = Integer(hash_intvalue(itr))
+- hash_next(itr)
+- return result
+-
+-
+-cdef dict vp_hashtab_to_dict(hashtab *ht):
+- """
+- Return a dictionary corresponding to the coproduct of a Schur function whose keys are
+- pairs of partitions and whose values are integers .
+-
+- EXAMPLES::
+-
+- sage: from sage.libs.lrcalc.lrcalc import coprod
+- sage: coprod([1]) #indirect doctest
+- {([1], []): 1}
++ sage: mult([2,1],[3,2,1],3) # indirect doctest
++ {[3, 3, 3]: 1, [4, 3, 2]: 2, [4, 4, 1]: 1, [5, 2, 2]: 1, [5, 3, 1]: 1}
+ """
+- cdef hash_itr itr
+- cdef vecpair* vp
+- cdef dict result = {}
+- hash_first(ht, itr)
+- while hash_good(itr):
+- vp = hash_key(itr)
+- p1 = _Partitions(vector_to_list(vp_first(vp)))
+- p2 = _Partitions(vector_to_list(vp_second(vp)))
+- result[(p1, p2)] = Integer(hash_intvalue(itr))
+- hash_next(itr)
+- return result
+-
++ return {_Partitions(la): Integer(k) for la, k in result.items()}
+
+ def lrcoef_unsafe(outer, inner1, inner2):
+ r"""
+@@ -371,13 +213,11 @@ def lrcoef_unsafe(outer, inner1, inner2):
+
+ INPUT:
+
+- - ``outer`` -- a partition (weakly decreasing list of non-negative integers).
+-
+- - ``inner1`` -- a partition.
++ - ``outer`` -- a partition (weakly decreasing list of non-negative integers)
++ - ``inner1`` -- a partition
++ - ``inner2`` -- a partition
+
+- - ``inner2`` -- a partition.
+-
+- .. warning::
++ .. WARNING::
+
+ This function does not do any check on its input. If you want
+ to use a safer version, use :func:`lrcoef`.
+@@ -392,18 +232,7 @@ def lrcoef_unsafe(outer, inner1, inner2):
+ sage: lrcoef_unsafe([2,1,1,1,1], [2,1], [2,1])
+ 0
+ """
+- cdef long long result
+- cdef vector *o
+- cdef vector *i1
+- cdef vector *i2
+- o = iterable_to_vector(outer)
+- i1 = iterable_to_vector(inner1)
+- i2 = iterable_to_vector(inner2)
+- result = lrcoef_c(o, i1, i2)
+- v_free(o)
+- v_free(i1)
+- v_free(i2)
+- return Integer(result)
++ return Integer(lrcalc.lrcoef(outer, inner1, inner2))
+
+
+ def lrcoef(outer, inner1, inner2):
+@@ -415,11 +244,9 @@ def lrcoef(outer, inner1, inner2):
+
+ INPUT:
+
+- - ``outer`` -- a partition (weakly decreasing list of non-negative integers).
+-
+- - ``inner1`` -- a partition.
+-
+- - ``inner2`` -- a partition.
++ - ``outer`` -- a partition (weakly decreasing list of non-negative integers)
++ - ``inner1`` -- a partition
++ - ``inner2`` -- a partition
+
+ .. NOTE::
+
+@@ -436,7 +263,6 @@ def lrcoef(outer, inner1, inner2):
+ 1
+ sage: lrcoef([2,1,1,1,1], [2,1], [2,1])
+ 0
+-
+ """
+ return lrcoef_unsafe(_Partitions(outer), _Partitions(inner1), _Partitions(inner2))
+
+@@ -451,13 +277,9 @@ def mult(part1, part2, maxrows=None, level=None, quantum=None):
+ INPUT:
+
+ - ``part1`` -- a partition
+-
+ - ``part2`` -- a partition
+-
+ - ``maxrows`` -- (optional) an integer
+-
+ - ``level`` -- (optional) an integer
+-
+ - ``quantum`` -- (optional) an element of a ring
+
+ If ``maxrows`` is specified, then only partitions with at most
+@@ -479,7 +301,8 @@ def mult(part1, part2, maxrows=None, level=None, quantum=None):
+ sage: sorted(mult([2],[2]).items())
+ [([2, 2], 1), ([3, 1], 1), ([4], 1)]
+ sage: sorted(mult([2,1],[2,1]).items())
+- [([2, 2, 1, 1], 1), ([2, 2, 2], 1), ([3, 1, 1, 1], 1), ([3, 2, 1], 2), ([3, 3], 1), ([4, 1, 1], 1), ([4, 2], 1)]
++ [([2, 2, 1, 1], 1), ([2, 2, 2], 1), ([3, 1, 1, 1], 1),
++ ([3, 2, 1], 2), ([3, 3], 1), ([4, 1, 1], 1), ([4, 2], 1)]
+ sage: sorted(mult([2,1],[2,1],maxrows=2).items())
+ [([3, 3], 1), ([4, 2], 1)]
+ sage: mult([2,1],[3,2,1],3)
+@@ -510,44 +333,24 @@ def mult(part1, part2, maxrows=None, level=None, quantum=None):
+ if quantum is not None and (level is None or maxrows is None):
+ raise ValueError('missing parameters maxrows or level')
+
+- cdef vector* v1 = iterable_to_vector(part1)
+- cdef vector* v2 = iterable_to_vector(part2)
+- if maxrows is None:
+- maxrows = 0
+- cdef hashtab* ht = mult_c(v1, v2, int(maxrows))
+- cdef hashtab* tab
+- cdef dict result
+-
+ if quantum is None:
+ if level is not None:
+- fusion_reduce_c(ht, int(maxrows), int(level), int(0))
+- result = sf_hashtab_to_dict(ht)
+- v_free(v1)
+- v_free(v2)
+- hash_free(ht)
+- return result
++ return _lrcalc_dict_to_sage(lrcalc.mult_fusion(part1, part2, maxrows, level))
++ if maxrows is None:
++ maxrows = -1
++ return _lrcalc_dict_to_sage(lrcalc.mult(part1, part2, maxrows))
+
+ # Otherwise do quantum multiplication
+- cdef _list *qlist
+- cdef dict temp
+- qlist = quantum_reduce_c(ht, int(maxrows), int(level))
+- # The above call frees the memory associated with ht
+- v_free(v1)
+- v_free(v2)
+-
+- cdef Parent P = quantum.parent()
+- result = {}
+- for i in range(qlist.length):
+- tab = (qlist.array[i])
+- temp = sf_hashtab_to_dict(tab)
+- for k in temp:
+- result[k] = result.get(k, P.zero()) + quantum**i * temp[k]
+- hash_free(tab)
+- l_free(qlist)
+- return result
+-
+-
+-def skew(outer, inner, maxrows=0):
++ result = lrcalc.mult_quantum(part1, part2, maxrows, level, degrees=True)
++ P = quantum.parent()
++ output = {}
++ for i,k in result.items():
++ la = _Partitions(i[0])
++ output[la] = output.get(la, P.zero()) + k * quantum**(i[1])
++ return output
++
++
++def skew(outer, inner, maxrows=-1):
+ """
+ Compute the Schur expansion of a skew Schur function.
+
+@@ -557,11 +360,9 @@ def skew(outer, inner, maxrows=0):
+
+ INPUT:
+
+- - ``outer`` -- a partition.
+-
+- - ``inner`` -- a partition.
+-
+- - ``maxrows`` -- an integer or ``None``.
++ - ``outer`` -- a partition
++ - ``inner`` -- a partition
++ - ``maxrows`` -- an integer or ``None``
+
+ If ``maxrows`` is specified, then only partitions with at most
+ this number of rows are included in the result.
+@@ -572,14 +373,7 @@ def skew(outer, inner, maxrows=0):
+ sage: sorted(skew([2,1],[1]).items())
+ [([1, 1], 1), ([2], 1)]
+ """
+- cdef vector* v1 = iterable_to_vector(outer)
+- cdef vector* v2 = iterable_to_vector(inner)
+- cdef hashtab* ht = skew_c(v1, v2, int(maxrows))
+- result = sf_hashtab_to_dict(ht)
+- v_free(v1)
+- v_free(v2)
+- hash_free(ht)
+- return result
++ return _lrcalc_dict_to_sage(lrcalc.skew(outer, inner, maxrows))
+
+
+ def coprod(part, all=0):
+@@ -592,9 +386,8 @@ def coprod(part, all=0):
+
+ INPUT:
+
+- - ``part`` -- a partition.
+-
+- - ``all`` -- an integer.
++ - ``part`` -- a partition
++ - ``all`` -- an integer
+
+ If ``all`` is non-zero then all terms are included in the result.
+ If ``all`` is zero, then only pairs of partitions ``(part1,
+@@ -609,12 +402,9 @@ def coprod(part, all=0):
+ sage: sorted(coprod([2,1]).items())
+ [(([1, 1], [1]), 1), (([2], [1]), 1), (([2, 1], []), 1)]
+ """
+- cdef vector* v1 = iterable_to_vector(part)
+- cdef hashtab* ht = coprod_c(v1, int(all))
+- result = vp_hashtab_to_dict(ht)
+- v_free(v1)
+- hash_free(ht)
+- return result
++ result = lrcalc.coprod(part, all)
++ return {tuple([_Partitions(mu) for mu in la]): Integer(k)
++ for la, k in result.items()}
+
+
+ def mult_schubert(w1, w2, rank=0):
+@@ -627,11 +417,9 @@ def mult_schubert(w1, w2, rank=0):
+
+ INPUT:
+
+- - ``w1`` -- a permutation.
+-
+- - ``w2`` -- a permutation.
+-
+- - ``rank`` -- an integer.
++ - ``w1`` -- a permutation
++ - ``w2`` -- a permutation
++ - ``rank`` -- an integer
+
+ If ``rank`` is non-zero, then only permutations from the symmetric
+ group `S(\mathrm{rank})` are included in the result.
+@@ -646,33 +434,24 @@ def mult_schubert(w1, w2, rank=0):
+ ([6, 4, 3, 1, 2, 5], 1), ([6, 5, 2, 1, 3, 4], 1),
+ ([7, 3, 4, 1, 2, 5, 6], 1), ([7, 4, 2, 1, 3, 5, 6], 1)]
+ """
+- cdef vector* v1 = iterable_to_vector(w1)
+- cdef vector* v2 = iterable_to_vector(w2)
+- cdef hashtab* ht = mult_schubert_c(v1, v2, int(rank))
+- result = schubert_hashtab_to_dict(ht)
+- v_free(v1)
+- v_free(v2)
+- hash_free(ht)
+- return result
++ result = lrcalc.schubmult(w1, w2, rank)
++ return {Permutation(list(la)):Integer(k) for la,k in result.items()}
+
+
+-def lrskew(outer, inner, weight=None, maxrows=0):
++def lrskew(outer, inner, weight=None, maxrows=-1):
+ r"""
+ Iterate over the skew LR tableaux of shape ``outer / inner``.
+
+ INPUT:
+
+ - ``outer`` -- a partition
+-
+ - ``inner`` -- a partition
+-
+ - ``weight`` -- a partition (optional)
+-
+- - ``maxrows`` -- an integer (optional)
++ - ``maxrows`` -- a positive integer (optional)
+
+ OUTPUT: an iterator of :class:`SkewTableau`
+
+- Specifying ``maxrows`` restricts the alphabet to `\{1,2,\ldots,maxrows\}`.
++ Specifying ``maxrows`` = `M` restricts the alphabet to `\{1,2,\ldots,M\}`.
+
+ Specifying ``weight`` returns only those tableaux of given content/weight.
+
+@@ -702,22 +481,40 @@ def lrskew(outer, inner, weight=None, maxrows=0):
+
+ sage: list(lrskew([3,2,1],[2], weight=[3,1]))
+ [[[None, None, 1], [1, 1], [2]]]
++
++ TESTS::
++
++ sage: from sage.libs.lrcalc.lrcalc import lrskew
++ sage: list(lrskew([3,2,1],[2], weight=[]))
++ []
++ sage: list(lrskew([3,2,1],[2], weight=[0]))
++ []
++ sage: list(lrskew([3,2,1],[3,2,1], weight=[]))
++ [[[None, None, None], [None, None], [None]]]
++ sage: list(lrskew([3,2,1],[3,2,1], weight=[0]))
++ [[[None, None, None], [None, None], [None]]]
++ sage: list(lrskew([3,2,1],[3,2,1], weight=[1]))
++ []
+ """
+- cdef vector* o = iterable_to_vector(outer)
+- cdef vector* i = iterable_to_vector(inner + [0]*(len(outer) - len(inner)))
+- cdef skewtab* st = st_new(o, i, NULL, int(maxrows))
++ iterator = lrcalc.lr_iterator(outer, inner, maxrows)
++ shape = SkewPartition([outer, inner])
+
+ if weight is None:
+- yield skewtab_to_SkewTableau(st)
+- while st_next(st):
+- yield skewtab_to_SkewTableau(st)
++ ST = SemistandardSkewTableaux(shape)
++ for data in iterator:
++ yield ST.from_shape_and_word(shape, [i+1 for i in data])
+ else:
+ wt = _Partitions(weight)
+- r = skewtab_to_SkewTableau(st)
+- if r.weight() == wt:
+- yield r
+- while st_next(st):
+- r = skewtab_to_SkewTableau(st)
+- if r.weight() == wt:
+- yield r
+- st_free(st)
++ ST = SemistandardSkewTableaux(shape, wt)
++ m = len(wt)
++ for data in iterator:
++ w = [0] * m
++ for j in data:
++ if j >= m:
++ # We know they are not equal, so make the check below quick
++ w = None
++ break
++ w[j] += 1
++ if w == wt:
++ yield ST.from_shape_and_word(shape, [i+1 for i in data])
++
diff --git a/srcpkgs/sagemath/patches/trac-33170-fix_doctest_ipython_8.patch b/srcpkgs/sagemath/patches/trac-33170-fix_doctest_ipython_8.patch
new file mode 100644
index 0000000000..1e2e0ba907
--- /dev/null
+++ b/srcpkgs/sagemath/patches/trac-33170-fix_doctest_ipython_8.patch
@@ -0,0 +1,40 @@
+As produced by `git diff a90a3146{^^,}`
+
+diff --git a/src/sage/repl/interface_magic.py b/src/sage/repl/interface_magic.py
+index 8a455b69b0e..a93e1c9e04c 100644
+--- a/src/sage/repl/interface_magic.py
++++ b/src/sage/repl/interface_magic.py
+@@ -260,7 +260,7 @@ class InterfaceMagic(object):
+ 2
+ 120
+ sage: shell.run_cell('%%gap foo\n1+1;\n')
+- ...File "", line unknown
++ ...File......
+ SyntaxError: Interface magics have no options, got "foo"
+
+ sage: shell.run_cell('%%gap?')
+diff --git a/src/sage/repl/interpreter.py b/src/sage/repl/interpreter.py
+index 7468afe52d7..06c47b7374a 100644
+--- a/src/sage/repl/interpreter.py
++++ b/src/sage/repl/interpreter.py
+@@ -78,9 +78,9 @@ Check that Cython source code appears in tracebacks::
+ dummy line
+ ...
+ ZeroDivisionError...Traceback (most recent call last)
+- in ...
++ ...in ...
+ ----> 1 Integer(1)/Integer(0)
+- .../sage/rings/integer.pyx in sage.rings.integer.Integer...div...
++ .../sage/rings/integer.pyx... in sage.rings.integer.Integer...div...
+ ...
+ -> ... raise ZeroDivisionError("rational division by zero")
+ ....: x = Rational.__new__(Rational)
+@@ -423,7 +423,7 @@ def SagePreparseTransformer(lines):
+ sage: from sage.repl.interpreter import get_test_shell
+ sage: shell = get_test_shell()
+ sage: shell.run_cell(bad_syntax)
+- File "", line unknown
++ File......
+ SyntaxError: Mismatched ']'
+
+ sage: shell.quit()
diff --git a/srcpkgs/sagemath/patches/trac-33170b-fix_doctest_ipython_8.1.patch b/srcpkgs/sagemath/patches/trac-33170b-fix_doctest_ipython_8.1.patch
new file mode 100644
index 0000000000..853813b0f5
--- /dev/null
+++ b/srcpkgs/sagemath/patches/trac-33170b-fix_doctest_ipython_8.1.patch
@@ -0,0 +1,13 @@
+Fix for ipython 8.1
+
+--- a/src/sage/repl/interpreter.py
++++ b/src/sage/repl/interpreter.py
+@@ -78,7 +78,7 @@ Check that Cython source code appears in tracebacks::
+ dummy line
+ ...
+ ZeroDivisionError...Traceback (most recent call last)
+- ...in ...
++ ...
+ ----> 1 Integer(1)/Integer(0)
+ .../sage/rings/integer.pyx... in sage.rings.integer.Integer...div...
+ ...
diff --git a/srcpkgs/sagemath/patches/trac-33336-fix_doctest_scipy_1.8.patch b/srcpkgs/sagemath/patches/trac-33336-fix_doctest_scipy_1.8.patch
new file mode 100644
index 0000000000..19b69700a4
--- /dev/null
+++ b/srcpkgs/sagemath/patches/trac-33336-fix_doctest_scipy_1.8.patch
@@ -0,0 +1,19 @@
+commit 9c8235e44ffb509efa8a3ca6cdb55154e2b5066d
+Author: Antonio Rojas
+Date: Sun Feb 13 19:53:14 2022 +0100
+
+ Fix deprecation warning with scipy 1.8
+
+diff --git a/src/sage/tests/books/computational-mathematics-with-sagemath/linsolve_doctest.py b/src/sage/tests/books/computational-mathematics-with-sagemath/linsolve_doctest.py
+index e9b60dae5ec..7932167b41d 100644
+--- a/src/sage/tests/books/computational-mathematics-with-sagemath/linsolve_doctest.py
++++ b/src/sage/tests/books/computational-mathematics-with-sagemath/linsolve_doctest.py
+@@ -356,7 +356,7 @@ Sage example in ./linsolve.tex, line 2230::
+
+ Sage example in ./linsolve.tex, line 2609::
+
+- sage: from scipy.sparse.linalg.dsolve import *
++ sage: from scipy.sparse.linalg import factorized
+ sage: from scipy.sparse import lil_matrix
+ sage: from numpy import array
+ sage: n = 200
diff --git a/srcpkgs/sagemath/patches/trac-33398-fix_doctest_sympy_1.10-609dd9deaeaa6380ab2f0d50276d911233c00a04.patch b/srcpkgs/sagemath/patches/trac-33398-fix_doctest_sympy_1.10-609dd9deaeaa6380ab2f0d50276d911233c00a04.patch
new file mode 100644
index 0000000000..9ba7ca5a6b
--- /dev/null
+++ b/srcpkgs/sagemath/patches/trac-33398-fix_doctest_sympy_1.10-609dd9deaeaa6380ab2f0d50276d911233c00a04.patch
@@ -0,0 +1,99 @@
+From 609dd9deaeaa6380ab2f0d50276d911233c00a04 Mon Sep 17 00:00:00 2001
+From: Matthias Koeppe
+Date: Fri, 4 Mar 2022 16:07:09 -0800
+Subject: sage.manifolds: Update doctests for SymPy 1.10
+
+---
+ src/sage/manifolds/continuous_map.py | 3 +--
+ src/sage/manifolds/differentiable/diff_form.py | 4 ++--
+ src/sage/manifolds/differentiable/tensorfield.py | 8 ++++----
+ src/sage/manifolds/vector_bundle_fiber_element.py | 2 +-
+ 4 files changed, 8 insertions(+), 9 deletions(-)
+
+diff --git a/src/sage/manifolds/continuous_map.py b/src/sage/manifolds/continuous_map.py
+index a6356e7..f6f9b6d 100644
+--- a/src/sage/manifolds/continuous_map.py
++++ b/src/sage/manifolds/continuous_map.py
+@@ -1357,8 +1357,7 @@ class ContinuousMap(Morphism):
+ sage: Phi.coord_functions(c_uv, c_xyz)
+ Coordinate functions (u*v, u/v, u + v) on the Chart (M, (u, v))
+ sage: Phi.coord_functions(c_UV, c_xyz)
+- Coordinate functions (-U**2/4 + V**2/4, -(U + V)/(U - V), V)
+- on the Chart (M, (U, V))
++ Coordinate functions (-U**2/4 + V**2/4, (-U - V)/(U - V), V) on the Chart (M, (U, V))
+ sage: Phi.coord_functions(c_UV, c_XYZ)
+ Coordinate functions ((-U**3 + U**2*V + U*V**2 + 2*U*V + 6*U - V**3
+ - 2*V**2 + 6*V)/(2*(U - V)), (U**3/4 - U**2*V/4 - U*V**2/4 + U*V
+diff --git a/src/sage/manifolds/differentiable/diff_form.py b/src/sage/manifolds/differentiable/diff_form.py
+index 70dd8fb..0aa3469 100644
+--- a/src/sage/manifolds/differentiable/diff_form.py
++++ b/src/sage/manifolds/differentiable/diff_form.py
+@@ -266,7 +266,7 @@ class DiffForm(TensorField):
+
+ sage: s = a.wedge(b)
+ sage: s.display(eU)
+- a∧b = -x*(2*x*y + 1) dx∧dy
++ a∧b = x*(-2*x*y - 1) dx∧dy
+ sage: s.display(eV)
+ a∧b = (u**3/8 + u**2*v/8 - u*v**2/8 + u/4 - v**3/8 + v/4) du∧dv
+
+@@ -275,7 +275,7 @@ class DiffForm(TensorField):
+ sage: f = M.scalar_field({c_xy: (x+y)^2, c_uv: u^2}, name='f')
+ sage: s = f*a
+ sage: s.display(eU)
+- f*a = -y*(x**2 + 2*x*y + y**2) dx + x*(x**2 + 2*x*y + y**2) dy
++ f*a = y*(-x**2 - 2*x*y - y**2) dx + x*(x**2 + 2*x*y + y**2) dy
+ sage: s.display(eV)
+ f*a = u**2*v/2 du - u**3/2 dv
+
+diff --git a/src/sage/manifolds/differentiable/tensorfield.py b/src/sage/manifolds/differentiable/tensorfield.py
+index 2775be9..6bc5c50 100644
+--- a/src/sage/manifolds/differentiable/tensorfield.py
++++ b/src/sage/manifolds/differentiable/tensorfield.py
+@@ -334,7 +334,7 @@ class TensorField(ModuleElementWithMutability):
+ sage: f.display() # long time
+ t(a,b): S^2 → ℝ
+ on U: (x, y) ↦ -2*x*y - 3*x - y**2
+- on V: (u, v) ↦ -(3*u**3 + 3*u*v**2 + 2*u*v + v**2)/(u**4 + 2*u**2*v**2 + v**4)
++ on V: (u, v) ↦ (-3*u**3 - 3*u*v**2 - 2*u*v - v**2)/(u**4 + 2*u**2*v**2 + v**4)
+
+ The vectors can be defined only on subsets of `S^2`, the domain of the
+ result is then the common subset::
+@@ -343,12 +343,12 @@ class TensorField(ModuleElementWithMutability):
+ sage: s.display() # long time
+ t(a,b): U → ℝ
+ (x, y) ↦ -2*x*y - 3*x - y**2
+- on W: (u, v) ↦ -(3*u**3 + 3*u*v**2 + 2*u*v + v**2)/(u**4 + 2*u**2*v**2 + v**4)
++ on W: (u, v) ↦ (-3*u**3 - 3*u*v**2 - 2*u*v - v**2)/(u**4 + 2*u**2*v**2 + v**4)
+ sage: s = t(a.restrict(U), b.restrict(W)) # long time
+ sage: s.display() # long time
+ t(a,b): W → ℝ
+ (x, y) ↦ -2*x*y - 3*x - y**2
+- (u, v) ↦ -(3*u**3 + 3*u*v**2 + 2*u*v + v**2)/(u**4 + 2*u**2*v**2 + v**4)
++ (u, v) ↦ (-3*u**3 - 3*u*v**2 - 2*u*v - v**2)/(u**4 + 2*u**2*v**2 + v**4)
+
+ The tensor itself can be defined only on some open subset of `S^2`,
+ yielding a result whose domain is this subset::
+@@ -356,7 +356,7 @@ class TensorField(ModuleElementWithMutability):
+ sage: s = t.restrict(V)(a,b) # long time
+ sage: s.display() # long time
+ t(a,b): V → ℝ
+- (u, v) ↦ -(3*u**3 + 3*u*v**2 + 2*u*v + v**2)/(u**4 + 2*u**2*v**2 + v**4)
++ (u, v) ↦ (-3*u**3 - 3*u*v**2 - 2*u*v - v**2)/(u**4 + 2*u**2*v**2 + v**4)
+ on W: (x, y) ↦ -2*x*y - 3*x - y**2
+
+ Tests regarding the multiplication by a scalar field::
+diff --git a/src/sage/manifolds/vector_bundle_fiber_element.py b/src/sage/manifolds/vector_bundle_fiber_element.py
+index 29ee81d..048275a 100644
+--- a/src/sage/manifolds/vector_bundle_fiber_element.py
++++ b/src/sage/manifolds/vector_bundle_fiber_element.py
+@@ -110,4 +110,4 @@ class VectorBundleFiberElement(FiniteRankFreeModuleElement):
+ desc += str(self._name) + " "
+ desc += "in the fiber of {} at {}".format(self._vbundle._name,
+ self._point)
+- return desc
+\ No newline at end of file
++ return desc
+--
+cgit v1.0-1-gd88e
+
diff --git a/srcpkgs/sagemath/patches/trac-33398-fix_doctest_sympy_1.10-c49eff347454ac7f07e5918470b20e97b8f2357e.patch b/srcpkgs/sagemath/patches/trac-33398-fix_doctest_sympy_1.10-c49eff347454ac7f07e5918470b20e97b8f2357e.patch
new file mode 100644
index 0000000000..f5ac180baa
--- /dev/null
+++ b/srcpkgs/sagemath/patches/trac-33398-fix_doctest_sympy_1.10-c49eff347454ac7f07e5918470b20e97b8f2357e.patch
@@ -0,0 +1,29 @@
+From c49eff347454ac7f07e5918470b20e97b8f2357e Mon Sep 17 00:00:00 2001
+From: Matthias Koeppe
+Date: Fri, 4 Mar 2022 15:14:43 -0800
+Subject: src/sage/calculus/calculus.py: Update laplace doctest for sympy 1.10
+
+---
+ src/sage/calculus/calculus.py | 6 +++---
+ 1 file changed, 3 insertions(+), 3 deletions(-)
+
+diff --git a/src/sage/calculus/calculus.py b/src/sage/calculus/calculus.py
+index 9c2f226..b335093 100644
+--- a/src/sage/calculus/calculus.py
++++ b/src/sage/calculus/calculus.py
+@@ -1639,9 +1639,9 @@ def laplace(ex, t, s, algorithm='maxima'):
+ sage: laplace(dirac_delta(t), t, s)
+ 1
+ sage: F, a, cond = laplace(dirac_delta(t), t, s, algorithm='sympy')
+- sage: a, cond
+- (-oo, True)
+- sage: F # random - sympy <1.9 includes undefined heaviside(0) in answer
++ sage: a, cond # random - sympy <1.10 gives (-oo, True)
++ (0, True)
++ sage: F # random - sympy <1.9 includes undefined heaviside(0) in answer
+ 1
+ sage: laplace(dirac_delta(t), t, s, algorithm='giac')
+ 1
+--
+cgit v1.0-1-gd88e
+
diff --git a/srcpkgs/sagemath/patches/trac-33585-fix_doctest_sphinx_installed-a04a0a0b14f67f4804e7113c3db41bbcf8a58296.patch b/srcpkgs/sagemath/patches/trac-33585-fix_doctest_sphinx_installed-a04a0a0b14f67f4804e7113c3db41bbcf8a58296.patch
new file mode 100644
index 0000000000..8e7bb64f5b
--- /dev/null
+++ b/srcpkgs/sagemath/patches/trac-33585-fix_doctest_sphinx_installed-a04a0a0b14f67f4804e7113c3db41bbcf8a58296.patch
@@ -0,0 +1,26 @@
+From a04a0a0b14f67f4804e7113c3db41bbcf8a58296 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?=
+Date: Mon, 28 Mar 2022 20:39:59 -0300
+Subject: Trac #33585: fix doctest when dochtml is missing...
+
+...but sphinx is available in PYTHONPATH.
+---
+ src/sage/misc/sagedoc.py | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/src/sage/misc/sagedoc.py b/src/sage/misc/sagedoc.py
+index 4b3853f..08c4225 100644
+--- a/src/sage/misc/sagedoc.py
++++ b/src/sage/misc/sagedoc.py
+@@ -1401,7 +1401,7 @@ class _sage_doc:
+ "...**File:**...**Type:**...**Definition:** identity_matrix..."
+ sage: identity_matrix.__doc__ in browse_sage_doc(identity_matrix, 'rst')
+ True
+- sage: browse_sage_doc(identity_matrix, 'html', False) # optional - sphinx
++ sage: browse_sage_doc(identity_matrix, 'html', False) # optional - sphinx sagemath_doc_html
+ '...div...File:...Type:...Definition:...identity_matrix...'
+
+ In the 'text' version, double colons have been replaced with
+--
+cgit v1.0-1-gd88e
+
diff --git a/srcpkgs/sagemath/patches/zzz-skip_doctest_no_threejs.patch b/srcpkgs/sagemath/patches/zzz-skip_doctest_no_threejs.patch
deleted file mode 100644
index 5cb62f56e9..0000000000
--- a/srcpkgs/sagemath/patches/zzz-skip_doctest_no_threejs.patch
+++ /dev/null
@@ -1,13 +0,0 @@
- - we don't have threejs in void
-
---- a/src/sage/repl/ipython_kernel/install.py
-+++ b/src/sage/repl/ipython_kernel/install.py
-@@ -124,7 +124,7 @@ class SageKernelSpec(object):
- sage: spec = SageKernelSpec(prefix=tmp_dir())
- sage: spec.use_local_threejs()
- sage: threejs = os.path.join(spec.nbextensions_dir, 'threejs-sage')
-- sage: os.path.isdir(threejs)
-+ sage: os.path.isdir(threejs) # optional - threejs
- True
- """
- src = THREEJS_DIR
diff --git a/srcpkgs/sagemath/template b/srcpkgs/sagemath/template
index 710a9e80c0..0d793262d5 100644
--- a/srcpkgs/sagemath/template
+++ b/srcpkgs/sagemath/template
@@ -1,7 +1,7 @@
# Template file for 'sagemath'
pkgname=sagemath
version=9.5
-revision=1
+revision=2
wrksrc=sage-$version
build_wrksrc=pkgs/sagemath-standard
build_style=python3-module
@@ -12,7 +12,7 @@ hostmakedepends="m4 pkg-config python3-Cython python3-Jinja2 python3-pkgconfig
makedepends="arb-devel boost-devel brial-devel cliquer-devel ecl eclib-devel
ecm-devel fflas-ffpack flintlib-devel gap-devel gd-devel giac-devel glpk-devel
gsl-devel iml-devel lcalc-devel libbraiding-devel libhomfly-devel libmpc-devel
- libpng-devel linbox-devel lrcalc-devel m4ri-devel m4rie-devel mpfi-devel
+ libpng-devel linbox-devel m4ri-devel m4rie-devel mpfi-devel
mpfr-devel ntl-devel openblas-devel pari-devel planarity-devel python3-cypari2
python3-cysignals python3-devel python3-gmpy2 python3-memory_allocator
python3-numpy rankwidth-devel singular symmetrica-devel zn_poly"
@@ -20,13 +20,13 @@ depends="FlintQS eclib-devel fflas-ffpack flintlib-devel gcc-fortran gd-devel
gfan giac gsl-devel gzip libpng-devel linbox-devel m4ri-devel maxima-ecl
mpfr-devel nauty ntl-devel palp pari-devel pari-elldata-small pari-galdata
pari-galpol-small pari-seadata-small pkg-config python3-Cython python3-cypari2
- python3-cysignals python3-devel python3-fpylll python3-ipython
+ python3-cysignals python3-devel python3-fpylll python3-ipython python3-lrcalc
python3-ipython_ipykernel python3-jupyter_ipywidgets python3-matplotlib
python3-memory_allocator python3-networkx python3-pip python3-pkgconfig
python3-pplpy python3-primecountpy python3-requests python3-scipy
python3-sympy python3-traitlets sage-data-combinatorial_designs
sage-data-conway_polynomials sage-data-elliptic_curves sage-data-graphs
- sage-data-polytopes_db sympow tachyon"
+ sage-data-polytopes_db sympow tachyon threejs-sage"
checkdepends="$depends"
short_desc="Open source mathematics software"
maintainer="Gonzalo Tornaría "
@@ -55,6 +55,7 @@ do_configure() {
COMBINATORIAL_DESIGN_DATA_DIR = "/usr/share/sagemath/combinatorial_designs"
CREMONA_MINI_DATA_DIR = "/usr/share/sagemath/cremona"
CREMONA_LARGE_DATA_DIR = "/usr/share/sagemath/cremona"
+ THREEJS_DIR = "/usr/share/sagemath/threejs-sage"
EOF
# don't install sage-venv-config: it is used to set SAGE_VENV=/usr and